tf.placeholder(dtype, shape=None, name=None)###
Inserts a placeholder for a tensor that will be always fed.
插入一個待初始化的張量占位符
Important: This tensor will produce an error if evaluated. Its value must be fed using the feed_dict optional argument to Session.run(), Tensor.eval(), or Operation.run().
For example:
x = tf.placeholder(tf.float32, shape=(1024, 1024))y = tf.matmul(x, x)with tf.Session() as sess: print(sess.run(y)) # ERROR: will fail because x was not fed. rand_array = np.random.rand(1024, 1024) print(sess.run(y, feed_dict={x: rand_array})) # Will succeed.
重要事項:這個張量被求值時會產生錯誤。 它的值必須在Session.run(), Tensor.eval() 或 Operation.run() 中使用feed_dict的這個可選參數來填充。
例外:
Args:
dtype: The type of elements in the tensor to be fed.
shape: The shape of the tensor to be fed (optional). If the shape is not specified, you can feed a tensor of any shape.
name: A name for the operation (optional).
參數:
dtype:被填充的張量的元素類型爽冕。
shape:被填充張量的形狀(可選參數)没讲。如果沒有指定張量打形狀爬凑,你可以填充該張量為任意形狀迁霎。
name:為該操作提供一個名字(可選參數)昌粤。
Returns:
A Tensor. that may be used as a handle for feeding a value, but not evaluated directly.
返回值:
一個張量. 必須在使用句柄的情況下賦值,但不可以直接求值。