megengine.functional.nn.dropout#
- dropout(inp, drop_prob, training=True)[source]#
Returns a new tensor where each of the elements are randomly set to zero with probability P =
drop_prob
. Optionally rescale the output tensor iftraining
is True.- Parameters:
- Return type:
- Returns:
the ouput tensor
Examples
>>> import numpy as np >>> data = Tensor(np.ones(10000000, dtype=np.float32)) >>> out = F.nn.dropout(data, 1.0 / 3.0, training=True) >>> assert not out.numpy().all() >>> out = F.nn.dropout(data, 1.0 / 3.0, training=False) >>> assert out.numpy().all() >>> out.numpy() array([1., 1., 1., ..., 1., 1., 1.], dtype=float32)