A quick glance throughtensorflow/python/layers/core.pyandtensorflow/python/ops/nn_ops.pyreveals thatis a wrapper for. tf.layers.dropout
tf.nn.dropout
You want to use the dropout() function in tensorflow.contrib.layers, not the one in tensorflow.nn.
The only differences in the two functions are:
- Thehas parameter: "Probability that each element is kept"has parameter: "The dropout rate" Thus,as definedhere
tf.nn.dropout
keep_prob
tf.layers.dropout
rate
keep_prob = 1 - rate
- Thehasparameter: "Whether to return the output in training mode (apply dropout) or in inference mode (return the input untouched)." The first one turns off(no-op) when not training, which is what you want, while the sec‐ond one does not.
tf.layers.dropout
training