Dropout#
- classtorch.nn.modules.dropout.Dropout(p=0.5,inplace=False)[source]#
During training, randomly zeroes some of the elements of the input tensor with probability
p.The zeroed elements are chosen independently for each forward call and are sampled from a Bernoulli distribution.
Each channel will be zeroed out independently on every forward call.
This has proven to be an effective technique for regularization andpreventing the co-adaptation of neurons as described in the paperImproving neural networks by preventing co-adaptation of featuredetectors .
Furthermore, the outputs are scaled by a factor of duringtraining. This means that during evaluation the module simply computes anidentity function.
- Parameters
- Shape:
Input:. Input can be of any shape
Output:. Output is of the same shape as input
Examples:
>>>m=nn.Dropout(p=0.2)>>>input=torch.randn(20,16)>>>output=m(input)