stanford-tensorflow-tutorials icon indicating copy to clipboard operation
stanford-tensorflow-tutorials copied to clipboard

The setting of dropout at './examples/07_convnet_layers.py' looks weird

Open LorrinWWW opened this issue 7 years ago • 1 comments

at line 66 dropout = tf.layers.dropout(fc, self.keep_prob, training=self.training, name='dropout') where self.training is a python boolean and it seems that updating self.training won't influence dropout. Thus, since it is initially set as 'False', the dropout layer won't work at all. Maybe it is better to set self.training as a tensorflow boolean scalar tensor (e.g. a placeholder)? Is there any more elegant way to do the same thing so that I don't need to use placeholder and feed_dict?

LorrinWWW avatar Mar 11 '18 22:03 LorrinWWW

I think tf.layers.dropout is designed for tf.estimator. See https://github.com/tensorflow/tensorflow/blob/r1.8/tensorflow/examples/tutorials/layers/cnn_mnist.py for an example. To use low level API, it seems we still need a placeholder.

fancyerii avatar Jun 25 '18 13:06 fancyerii