美文网首页
TensorFLow 函数翻译 — tf.placeholder

TensorFLow 函数翻译 — tf.placeholder

作者: HabileBadger | 来源:发表于2016-12-21 16:16 被阅读2773次

    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.

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

    相关文章

      网友评论

          本文标题:TensorFLow 函数翻译 — tf.placeholder

          本文链接:https://www.haomeiwen.com/subject/aipqvttx.html