2、tf.placeholder(dtype, shape=None, name=None)

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

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,030评论 0 23
  • 一趟开往终将成为每人过去里的火车、 它依旧行驶在每一个春夏秋冬的季节、 看到窗外田地树林格外入眼帘的风景、 走走停...
    Cinko阅读 283评论 0 18
  • 微信平台的面世,更好地加强了人与人之间的沟通与交流。许久不见的朋友,能通过朋友圈了解各自的近况,知道对方安好与否;...
    向着太阳奔跑的石头阅读 240评论 0 1
  • 生活不止眼前的苟且还有诗和远方的田野你赤手空拳来到人世间为找到那片海不顾一切 今天偶然在豆瓣看到这句话,喜爱之余陷...
    慕玉珩阅读 317评论 1 1
  • 今天请假了,上午要去见个很重要的客户,参加不了大早会了,希望我期待的“抱抱”环节换成做运动或者跳舞吧,天越热,越要...
    纯流氓艺术家阅读 315评论 0 0