AI Logic

Glossary

Dropout

Updated:

Diagram of dropout

Explanation

Dropout is a regularization technique that randomly drops units in the input and hidden layers of a neural network.

When a unit is dropped, its incoming and outgoing connections are temporarily removed from the network.

For the value of Dropout, the paper suggests either choosing 0.5 (randomly dropping 50% of the units), which is close to optimal, or selecting an appropriate value using a validation dataset.

However, for the input layer, the optimal probability of keeping a unit is usually closer to 1 than to 0.5 (that is, the Dropout rate should be smaller than 0.5).

(Image: taken from Dropout: Preventing Overfitting in Neural Networks (2014).)

Where It Is Used

Dropout is used especially in the following tasks and situations. In image recognition, applying dropout to the hidden layers of a convolutional neural network (CNN) improves the model's generalization ability. In natural language processing, it helps suppress overfitting in recurrent neural networks (RNNs) and long short-term memory (LSTM) units. In a multilayer perceptron (MLP) with fully connected layers, dropout can also be applied to hidden units and the output layer to strengthen the model. In addition, dropout is used in combination with the learning rate and other regularization techniques (e.g., L2 regularization) to achieve more effective performance. It is also recommended to try different drop rates (e.g., 0.2 or 0.5) to find the best fit.

PyTorch example

Show code
python
import torch.nn as nn

class NN(nn.Module):
  def __init__(self):
    super().__init__()
    self.mlp = nn.Linear(90, 90)    # The last tensor shape is from 90 to 90.
    self.dropout = nn.Dropout(0.5)  # 50% of the units are dropped out during training.
  
  def forward(self, x):
    x = self.mlp(x)
    x = self.dropout(x)
    return x

FAQ

Q. Why is dropout used?
A.

To prevent overfitting and improve the model's generalization performance. Randomly disabling neurons has an effect similar to training many subnetworks.

Q. How does it work?
A.

During training, neurons are disabled with a fixed probability, and learning proceeds with the resulting subnetwork. At inference, all neurons are used and the outputs are scaled to keep them consistent.

Q. Where is it used?
A.

It is still widely used today. Specifically, it is adopted in many deep learning architectures, such as image recognition (CNN), natural language processing (RNN, LSTM) and multilayer perceptrons (MLP).