1. 程式人生 > >Tensorflow學習筆記(2):tf.nn.dropout 與 tf.layers.dropout

Tensorflow學習筆記(2):tf.nn.dropout 與 tf.layers.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:

  1. Thetf.nn.dropouthas parameterkeep_prob: "Probability that each element is kept"
    tf.layers.dropouthas parameterrate: "The dropout rate"
    Thus,keep_prob = 1 - rate
    as definedhere
  2. Thetf.layers.dropouthastrainingparameter: "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.