Home Knowledge Base Weight Decay

Weight Decay is the regularization technique that penalizes large weight values by adding a fraction of the weight magnitude to the loss function or directly shrinking weights toward zero at each update step — preventing overfitting by discouraging the model from relying on any single feature too heavily, and representing one of the most universally applied and effective regularization methods across all deep learning architectures.

L2 Regularization vs. Decoupled Weight Decay

AdamW vs. Adam + L2

Adam + L2 regularization:
  g_t = ∇L(w) + 2λw        (L2 added to gradient)
  m_t = β₁m_{t-1} + (1-β₁)g_t
  v_t = β₂v_{t-1} + (1-β₂)g_t²
  w = w - lr × m_t / (√v_t + ε)
  # Problem: Decay is scaled by 1/√v_t → uneven

AdamW (decoupled weight decay):
  g_t = ∇L(w)              (gradient without L2)
  m_t = β₁m_{t-1} + (1-β₁)g_t
  v_t = β₂v_{t-1} + (1-β₂)g_t²
  w = w - lr × m_t / (√v_t + ε) - lr × λ × w
  # Decay is uniform → better regularization

Typical Weight Decay Values

Model TypeWeight Decay (λ)Notes
CNN (ResNet, etc.)1e-4 to 5e-4Standard for ImageNet training
Transformer (NLP)0.01 to 0.1Higher values common in LLMs
LLM pre-training0.1GPT-3, LLaMA use λ=0.1
Fine-tuning0.0 to 0.01Lower to preserve pre-trained features
ViT0.05 to 0.3Vision transformers need stronger regularization

What NOT to Decay

Effect of Weight Decay

Weight decay is the most fundamental regularization technique in deep learning — its simplicity and universal effectiveness across architectures make it one of the few hyperparameters that is always present in modern training configurations, with the AdamW formulation establishing decoupled weight decay as the standard for transformer-based models.

weight decayl2 regularizationdecoupled weight decayadamw weight decayregularization strength

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.