1. tf.placeholder
A placeholder is simply a variable that we will assign data to at a later date. It allows us to create our operations and build our computation graph, without needing the data. In TensorFlow terminology, we then feed data into the graph through these placeholders.
矩阵相乘
3. tf.Variable
A placeholder is simply a variable that we will assign data to at a later date. It allows us to create our operations and build our computation graph, without needing the data. In TensorFlow terminology, we then feed data into the graph through these placeholders.
import tensorflow as tf x = tf.placeholder("float", None) y = x * 2 with tf.Session() as session: result = session.run(y, feed_dict={x: [1, 2, 3]}) print(result)2. tf.matmul
矩阵相乘
3. tf.Variable
import tensorflow as tf x = tf.constant(35, name='x') y = tf.Variable(x + 5, name='y') print(y) # y.value 0 model = tf.global_variables_initializer() with tf.Session() as session: session.run(model) print(session.run(y)) # 40
本文介绍了TensorFlow中三种基本操作:使用tf.placeholder定义占位符以便稍后输入数据;使用tf.matmul进行矩阵相乘;使用tf.Variable定义变量,并通过会话运行初始化及计算过程。
730

被折叠的 条评论
为什么被折叠?



