What's the difference between tf.placeholder and tf.Variable

来源:互联网 发布:java键盘 上下左右监听 编辑:程序博客网 时间:2024/05/19 18:46

https://stackoverflow.com/questions/36693740/whats-the-difference-between-tf-placeholder-and-tf-variable

down vote
The difference is that with tf.Variable you have to provide an initial value when you declare it. With tf.placeholder you don’t have to provide an initial value and you can specify it at run time with the feed_dict argument inside Session.run

placeholder 用来表示输入和输出数据,不需要有初始值

for step in xrange(FLAGS.max_steps):    feed_dict = {       images_placeholder: images_feed,       labels_placeholder: labels_feed,     }    _, loss_value = sess.run([train_op, loss], feed_dict=feed_dict)

Variable 在Seesion训练时候会改变,而且需要有初始值

阅读全文
0 0
原创粉丝点击