tensorflow框架

一、tensorflow的工作流程,实际上它体现出来的是一个”懒性“方法论

(1)构建一个计算图。

(2)初始化变量

(3)创建一个会话

(4)在会话中运行图的计算

(5)关闭会话

二、神经网络搭建八股

1、基于Tensorflow的NN: 用张量表示数据,用计算图搭建神经网络,用会话执行计算图,优化线上的权重(参数),得到模型。

2、张量(tensor): 多维数组(列表)

import tensorflow as tf

a = tf.constant([1.0, 2.0])
b = tf.constant([3.0, 4.0])

result = a + b
print(result)

 Tensor("add:0", shape=(2,), dtype=float32)

 

二、计算图(Graph) : 搭建神经网络的计算过程,只搭建,不运算。

import tensorflow as tf
x = tf.constant([[1.0, 2.0]])
w = tf.constant([[3.0], [4.0]])
y = tf.matmul(x, w)

print(y)
with tf.Session() as sess:
print(sess.run(y))

前向传播

原文地址:https://www.cnblogs.com/zhaop8078/p/9534473.html