tensor:张量(数据)

flow:流动
Tensor-Flow:数据流
TensorFlow构成:图和会话
构建阶段:定义了数据(张量tensor)与操作(节点operation),构成图(静态)
张量:TensorFlow中的基本数据对象。
节点:提供图中执行的操作。
执行阶段:使用会话执行定义好的数据与操作。
#图(静态) a = tf.constant(2) #数据1(张量) b = tf.constant(6) #数据2(张量)
c = a + b #操作(节点)
#会话(执行)
with tf.Session() as sess:
print(sess.run(a + b))
#会话(执行)
with tf.Session() as sess:
print(sess.run([a,b,c]))
def Feed_Add():
#创建静态图
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = tf.add(a,b)
#会话(执行)
with tf.Session() as sess:
print(sess.run(c, feed_dict={a:0.5, b:2.0}))
import tensorflow as tf
def Add():
#图(静态)
a = tf.constant(2) #数据1(张量)
b = tf.constant(6) #数据2(张量)
c = a + b #操作(节点)
#会话(执行)
with tf.Session() as sess:
print(sess.run([a,b,c]))
def Feed_Add():
#创建静态图
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = tf.add(a,b)
#会话(执行)
with tf.Session() as sess:
print(sess.run(c, feed_dict={a:0.5, b:2.0}))
Add()
Feed_Add()
以上就是Python深度学习TensorFlow神经网络基础概括的详细内容,更多关于TensorFlow神经网络基础的资料请关注其它相关文章!