美文网首页
2、tf.placeholder(dtype, shape=No

2、tf.placeholder(dtype, shape=No

作者: liumw1203 | 来源:发表于2017-03-28 16:27 被阅读0次

    定义--简单一句话“接收数据集”

    tf.placeholder(dtype, shape=None, name=None)
    用于得到传递进来的真实的训练样本;
    不必指定初始值,可在运行时,通过 Session.run 的函数的 feed_dict 参数指定;
    这也是其命名的原因所在,仅仅作为一种占位符;

    例子

    x = tf.placeholder(float, 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.
    

    参数

    • dtype: 元素类型.
    • 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).

    返回

    A Tensor that may be used as a handle for feeding a value, but not evaluated directly.

    相关文章

      网友评论

          本文标题:2、tf.placeholder(dtype, shape=No

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