What are the Huber loss Lδ(r) for residual r=y^−y with threshold δ>0 and its derivative Lδ′(r)? For δ=1, what are Lδ(r) and Lδ′(r) at r=0.5 and r=4, and why does Huber loss combine the benefits of MSE and MAE?

Deep learning, Loss functions
Level L2 Elementary. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you know the piecewise definition of Huber loss, can compute its value and gradient, and understand its behaviour near zero versus on outliers.

Key idea

Huber loss is quadratic 12r2 for ∣r∣≤δ and linear δ(∣r∣−12δ) for ∣r∣>δ, with continuous derivative Lδ′(r)=clip⁡(r,−δ,δ). Near 0 its gradient shrinks linearly like MSE for smooth convergence, while for large residuals its gradient is capped at ±δ like MAE so outliers cannot dominate.

Steps

  1. Write the definition: Lδ(r)=12r2 if ∣r∣≤δ, and Lδ(r)=δ(∣r∣−12δ) if ∣r∣>δ. Notice both pieces equal 12δ2 and have derivative ±δ at ∣r∣=δ, so Lδ is C1-smooth.
  2. Derivative: Lδ′(r)=r for ∣r∣≤δ, and δ sign⁡(r) for ∣r∣>δ.
  3. Evaluate at δ=1,r=0.5 (∣r∣≤1): L1(0.5)=12(0.5)2=0.125, and L1′(0.5)=0.5.
  4. Evaluate at δ=1,r=4 (∣r∣>1): L1(4)=1⋅(4−0.5)=3.5, and L1′(4)=1.
  5. Contrast with MSE and MAE: pure MSE has L′(4)=4 (growing linearly with outliers, destabilising gradients), while pure MAE has ∣L′(r)∣=1 everywhere except a non-differentiable kink at 0 (causing oscillation near r=0 unless learning rate decays).

Common mistakes

How long your answer should be

Half a page; 4 minutes.

Last checked on 4 December 2026.

Read this

Previous in Deep learning: Is it true that an additive bias term b in a linear or convolutional layer immediately followed by batch normalisation is redundant, and why?
Next in Deep learning: How does clipping gradients by global L2 norm differ from clipping element-wise by value? Given a gradient vector g=[3,4]⊤ and threshold τ=2, what is the clipped gradient under each method, and which preserves the steepest-descent direction?