chiphuyen / stanford-tensorflow-tutorials

This repository contains code examples for the Stanford's course: TensorFlow for Deep Learning Research.
http://cs20.stanford.edu
MIT License
10.32k stars 4.32k forks source link

07_convnet_layers.py self.training should use tf.placeholder #142

Open TonyZZX opened 5 years ago

TonyZZX commented 5 years ago

If you use a Python bool, the value of training won't change because you already build the logits before the session and you can't change the graph during the session. The correct way should use tf.placeholder like this: self.training = tf.placeholder(tf.bool, name='is_train') And set sess.run(init, feed_dict={self.is_training: True}) when trainingand sess.run(init, feed_dict={self.is_training: False}) when evalating