tf.nn.dropout
tf.nn.dropout
tf.nn.dropout
dropout( x, keep_prob, noise_shape=None, seed=None, name=None )
Defined in tensorflow/python/ops/nn_ops.py
.
See the guides: Layers (contrib) > Higher level ops for building neural network layers, Neural Network > Activation Functions
Computes dropout.
With probability keep_prob
, outputs the input element scaled up by 1 / keep_prob
, otherwise outputs 0
. The scaling is so that the expected sum is unchanged.
By default, each element is kept or dropped independently. If noise_shape
is specified, it must be broadcastable to the shape of x
, and only dimensions with noise_shape[i] == shape(x)[i]
will make independent decisions. For example, if shape(x) = [k, l, m, n]
and noise_shape = [k, 1, 1, n]
, each batch and channel component will be kept independently and each row and column will be kept or not kept together.
Args:
-
x
: A tensor. -
keep_prob
: A scalarTensor
with the same type as x. The probability that each element is kept. -
noise_shape
: A 1-DTensor
of typeint32
, representing the shape for randomly generated keep/drop flags. -
seed
: A Python integer. Used to create random seeds. Seetf.set_random_seed
for behavior. -
name
: A name for this operation (optional).
Returns:
A Tensor of the same shape of x
.
Raises:
-
ValueError
: Ifkeep_prob
is not in(0, 1]
.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/nn/dropout