How are gradients handled at non-differentiable points of losses like MAE or hinge loss?

Quick Overview

Asks how optimizers compute gradients where losses such as MAE and hinge loss have a kink, and whether that choice matters. Tests understanding of subgradients, framework conventions at zero, learning rate schedules, and smooth or proximal alternatives.

How are gradients handled at non-differentiable points of losses like MAE or hinge loss?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Mean absolute error has a kink at zero residual, and hinge loss has one at the margin. How are gradients handled at these non-differentiable points during training, and does the choice made there matter? ```hint Left and right slopes Look at the left and right derivatives at the kink, and ask which slopes between them still give a valid linear lower bound on the loss. ``` ### What a Strong Answer Covers - What a subgradient is, and the set of valid values at the kinks of MAE and hinge loss - What deep learning frameworks actually return at those points, and why the choice rarely matters - How constant-magnitude subgradients affect convergence and the learning rate schedule - Smooth or proximal alternatives, and when they are worth using ### Follow-up Questions - Why does Huber loss behave better than MAE near the optimum, and how do you choose its threshold? - How does soft-thresholding produce exact zeros for L1 regularization when plain subgradient descent does not? - ReLU networks are not convex. What does a subgradient mean there, and does the value chosen at zero ever matter? - What optimality condition replaces "the gradient equals zero" for a convex non-differentiable loss?

Overview: Asks how optimizers compute gradients where losses such as MAE and hinge loss have a kink, and whether that choice matters. Tests understanding of subgradients, framework conventions at zero, learning rate schedules, and smooth or proximal alternatives.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Mean absolute error has a kink at zero residual, and hinge loss has one at the margin. How are gradients handled at these non-differentiable points during training, and does the choice made there matter?

What a Strong Answer Covers Guidance

  • What a subgradient is, and the set of valid values at the kinks of MAE and hinge loss
  • What deep learning frameworks actually return at those points, and why the choice rarely matters
  • How constant-magnitude subgradients affect convergence and the learning rate schedule
  • Smooth or proximal alternatives, and when they are worth using

Follow-up Questions Guidance

  • Why does Huber loss behave better than MAE near the optimum, and how do you choose its threshold?
  • How does soft-thresholding produce exact zeros for L1 regularization when plain subgradient descent does not?
  • ReLU networks are not convex. What does a subgradient mean there, and does the value chosen at zero ever matter?
  • What optimality condition replaces "the gradient equals zero" for a convex non-differentiable loss?