Tensorflow study notes (2): tf.nn.dropout and tf.layers.dropout

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:

  1. 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  
  2. 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 



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325779781&siteId=291194637