Table of Contents
Shortcuts

# Dropout

class torch.nn.Dropout(p=0.5, inplace=False)

  During training, randomly zeroes some of the elements of the input tensor with probability `p` using samples 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 and preventing the co-adaptation of neurons as described in the paper Improving neural networks by preventing co-adaptation of feature detectors .

  Furthermore, the outputs are scaled by a factor of 1 1−p\frac{1}{1-p}1−p 1​ during training. This means that during evaluation the module simply computes an identity function.

  Parameters:

    - p (float) – probability of an element to be zeroed. Default: 0.5

    - inplace (bool) – If set to `True`, will do this operation in-place. Default: `False`

  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)

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.