tf.placeholder

import numpy as np
import tensorflow as tf

p = tf.placeholder(dtype=tf.float32, shape=[1])
y = p

with tf.Session() as sess:
    d = np.random.rand(1)
    print(sess.run(y, feed_dict={p: d}))

占位符

tf.placeholder

不必指定初始值,可在运行时,通过 Session.runTensor.eval() 或者 Operation.run() 函数的 feed_dict 参数指定;

posted @ 2017-11-09 09:25  guqiangjs  阅读(270)  评论(0编辑  收藏  举报