TensorFLow 函数翻译 — tf.placeholder()

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.

返回值:
一个张量. 必须在使用句柄的情况下赋值,但不可以直接求值。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容