EasyDeepLearn

What is log-cosh loss and its advantage over Huber?

medium

Answer

  • L(y, ŷ) = log(cosh(y - ŷ)) ≈ 0.5(y)20.5 \cdot (y - )^{2} for small errors and  y\mathrm{and}\; \mid y-ŷ| - log(2)\operatorname{log}(2) for large — same behavior as Huber but smooth everywhere (all derivatives exist).
  • No δ hyperparameter.
  • Slightly more expensive to compute.
  • Use it when you want Huber's outlier-robustness without tuning δ, and gradient smoothness matters (e.g., second-order optimizers).

How to say it out loud

Log-cosh is the log of the hyperbolic cosine of the residual. For small errors it behaves like squared error, for large errors it grows linearly, so it is robust to outliers in the same way Huber is. The difference is that it is smooth everywhere, including across the transition, and there is no delta to tune. Huber has a kink at delta where the second derivative does not exist, which matters the moment you use anything second-order. What you give up is a slightly more expensive forward pass and any explicit control over where the transition sits — with Huber you choose it, with log-cosh you take what the function gives you.

Check yourself — multiple choice
  • Discontinuous
  • log(cosh(err))\operatorname{log}(\mathrm{cosh}(\mathrm{err})) — Huber-like behavior but smooth everywhere and no hyperparameter
  • Same as MAE
  • Only for classification

log-cosh: smooth everywhere Huber-alternative, no δ.

What the interviewer asks next

#losses

Practise Deep Learning

214 interview questions in this topic.

Related questions