🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Loss Functions for Deep Learning — MSE, Cross-Entropy, Focal Loss and Beyond

FoundationsLoss Functions🟢 Free Lesson

Advertisement

DL Foundations

Loss Functions — The Compass That Guides Neural Network Training

Loss functions quantify how wrong a model's predictions are, defining the objective that optimization algorithms minimize. Choosing the right loss function is critical for effective training and determines what the model learns.

  • Cross-Entropy Dominates — The standard loss for classification, equivalent to maximum likelihood estimation
  • Focal Loss for Imbalance — Down-weights easy examples to focus on hard, rare cases in object detection
  • Huber Loss for Robustness — Combines MSE and MAE to handle outliers in regression tasks

Loss Functions for Deep Learning — MSE, Cross-Entropy, Focal Loss and Beyond

Loss functions quantify how wrong a model's predictions are. Choosing the right loss function is critical for effective training.


Loss Function Taxonomy

Loss Function Decision TreeTask Type?RegressionMSE / MAE / HuberClassificationCross-Entropy / FocalRanking/SimilarityTriplet / ContrastiveOutliers? → HuberSymmetric? → MSERobust? → MAEBalanced? → CEImbalanced? → FocalLabel smoothing?

Mean Squared Error (MSE)

MSE Loss LandscapeMinimum∂L/∂ŷ > 0∂L/∂ŷ < 0L = (ŷ - y)² → ∂L/∂ŷ = 2(ŷ - y)

Cross-Entropy Loss

Cross-Entropy: Penalty vs Prediction ProbabilityPredicted probability (ŷ)Lossy=1: -log(ŷ)y=0: -log(1-ŷ)01High penalty when y=1, ŷ→0High penalty when y=0, ŷ→1

Focal Loss

Focal Loss: Down-weighting Easy ExamplesClassification Confidence (p_t)CE (γ=0)γ=1γ=2 (default)γ=5Easy (down-weighted)Hard (kept high)

Huber Loss


Contrastive and Triplet Loss


Loss Function Comparison

Regression Loss Functions ComparisonError (y - ŷ)LossMSEMAEHuberZero error

Label Smoothing


Summary

  • MSE for regression: quadratic penalty, sensitive to outliers
  • Cross-entropy for classification: equivalent to maximum likelihood
  • Focal loss handles class imbalance by down-weighting easy examples
  • Huber loss combines MSE and MAE for robustness
  • Triplet/contrastive loss for learning embeddings
  • Choose the loss function based on your task, data distribution, and what you want to optimize

Next: Optimizers for Deep Learning

Need Expert Deep Learning Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement