In tensorflow, we can use tf.layers.dropout() and tf.nn.dropout() to create a dropout layer. In this tutorial, we will introduce their difference.
tf.layers.dropout()
You can learn how to use tf.layers.dropout() in this tutorial:
Understand TensorFlow tf.nn.dropout(): A Beginner Guide – TensorFlow Tutorial
tf.layers.dropout()
It is defined as:
__init__( rate=0.5, noise_shape=None, seed=None, name=None, **kwargs )
We can find how to use rate in tf.layers.dropout()
In summation, in order to create and use dropout layer correctly, we should notice:
When training, we can set 0.5 in tf.layers.dropout() and tf.nn.dropout(). However, when testing, we should set 1.0 for tf.nn.dropout(), 0 for tf.layers.dropout().