With probability rate, drops elements of x. Input that are kept are
scaled up by 1 / (1 - rate), 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 floating point tensor.
rate
A scalar Tensor with the same type as x. The probability
that each element is dropped. For example, setting rate=0.1 would drop
10% of input elements.
noise_shape
A 1-D Tensor of type int32, representing the
shape for randomly generated keep/drop flags.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.nn.dropout\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/nn/dropout) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/nn_ops.py#L4232-L4317) |\n\nComputes dropout. \n\n tf.nn.dropout(\n x, rate, noise_shape=None, seed=None, name=None\n )\n\nWith probability `rate`, drops elements of `x`. Input that are kept are\nscaled up by `1 / (1 - rate)`, otherwise outputs `0`. The scaling is so that\nthe expected sum is unchanged.\n| **Note:** The behavior of dropout has changed between TensorFlow 1.x and 2.x. When converting 1.x code, please use named arguments to ensure behavior stays consistent.\n\nBy default, each element is kept or dropped independently. If `noise_shape`\nis specified, it must be\n[broadcastable](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)\nto the shape of `x`, and only dimensions with `noise_shape[i] == shape(x)[i]`\nwill make independent decisions. For example, if `shape(x) = [k, l, m, n]`\nand `noise_shape = [k, 1, 1, n]`, each batch and channel component will be\nkept independently and each row and column will be kept or not kept together.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | A floating point tensor. |\n| `rate` | A scalar `Tensor` with the same type as x. The probability that each element is dropped. For example, setting rate=0.1 would drop 10% of input elements. |\n| `noise_shape` | A 1-D `Tensor` of type `int32`, representing the shape for randomly generated keep/drop flags. |\n| `seed` | A Python integer. Used to create random seeds. See [`tf.compat.v1.set_random_seed`](../../tf/compat/v1/set_random_seed) for behavior. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A Tensor of the same shape of `x`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------------------------|\n| `ValueError` | If `rate` is not in `(0, 1]` or if `x` is not a floating point tensor. |\n\n\u003cbr /\u003e"]]