Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Dropout Layer

A dropout layer randomly zeroes a fraction of activations during training so a network cannot rely on any single unit, which reduces overfitting.

A dropout layer is a regularization component of a neural network that randomly sets a fraction p of its inputs to zero at every training step and passes all values through unchanged at inference. Because any unit can vanish at any step, the network cannot depend on a few specific neurons or on fragile co-adaptations between them, so it learns redundant features that generalize better and overfit the training data less. Geoffrey Hinton and colleagues introduced the technique in 2012, and Srivastava, Hinton, et al. described it in full in 2014. It is a built-in layer in PyTorch, TensorFlow, and most other deep learning frameworks, used in architectures from fully connected classifier heads to transformers.

How Dropout Works#

During training, the layer samples a fresh random mask for every forward pass, keeping each element with probability 1 − p and zeroing it with probability p. Each step therefore trains a different thinned subnetwork, and the full network used at test time approximates an average over the exponentially many subnetworks that share its weights, which is why dropout is often described as cheap ensemble training. To keep the expected activation the same in both phases, modern frameworks use inverted dropout: surviving values are multiplied by 1 / (1 − p) during training, so the layer does nothing at inference. In PyTorch, nn.Dropout follows the module's training or evaluation mode:

import torch
from torch import nn

torch.manual_seed(0)
dropout = nn.Dropout(p=0.5)
x = torch.ones(10)

# Training mode: about half the values are zeroed and survivors are scaled by 1 / (1 - p) = 2
dropout.train()
print("Train:", dropout(x))

# Evaluation mode: the layer passes every value through unchanged
dropout.eval()
print("Eval: ", dropout(x))

In training mode six of the ten values are dropped and the four survivors become 2.0, keeping the expected value at 1.0; in evaluation mode all ten values stay 1.0.

Common Dropout Variants#

  • Spatial Dropout: PyTorch's nn.Dropout2d zeroes entire feature-map channels, which suits convolutional networks because neighboring pixels within a channel are strongly correlated and dropping single pixels barely regularizes them.
  • Stochastic Depth (DropPath): Instead of individual activations, whole residual branches are skipped at random for each sample, a standard ingredient in training Vision Transformers and modern CNNs.
  • Monte Carlo Dropout: Dropout stays active at inference, and the model runs several forward passes on the same input. The spread of the predictions gives a low-cost estimate of model uncertainty for safety-critical systems, a method Gal and Ghahramani interpreted as approximate Bayesian inference.
  • DropConnect: Random individual weights are zeroed instead of activations, giving each connection its own mask.

Dropout in Practice#

Dropout rates are tuned like any other hyperparameter. Srivastava et al. found that dropping hidden units with probability 0.5 worked well across a wide range of networks and tasks, while input units do best with retention closer to 1, and the original Transformer used p = 0.1. Too high a rate slows convergence and can cause underfitting, and placing dropout directly before batch normalization can hurt accuracy through a train-to-test variance shift. Many convolutional neural networks rely mainly on batch normalization, data augmentation, and weight decay, keeping dropout for the classifier head. Ultralytics YOLO26 classification models follow that pattern: they contain one dropout layer, between the pooled 1,280-channel features and the final linear classifier, whose rate the dropout training argument sets (0.0 by default).

from ultralytics import YOLO

# Load a YOLO26 classification model, whose head contains the dropout layer
model = YOLO("yolo26n-cls.pt")

# Train with 10% dropout in the classification head on a small MNIST subset
results = model.train(data="mnist160", epochs=10, imgsz=64, dropout=0.1)

Real-World Applications#

  • Medical Image Analysis: Labeled scans are expensive, so diagnostic classifiers are often fine-tuned from a pretrained backbone on a few thousand images. Dropout in the classifier head limits how much the head memorizes individual cases from such a small set.
  • Natural Language Processing: Transformer encoders such as BERT apply dropout with probability 0.1 on all layers, including the attention weights, during pre-training and fine-tuning.
  • Batch Normalization: Batch normalization standardizes each layer's inputs to stabilize training and adds only mild noise from batch statistics, without removing any units.
  • Label Smoothing: Label smoothing regularizes through the training targets, softening one-hot labels, and leaves every activation intact.
  • Pruning: Pruning permanently removes low-importance weights to make a model smaller, while dropout's zeroing lasts a single training step and leaves the parameter count unchanged.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning