huber

std.loss.huber · Level L1

Huber loss: quadratic for small errors, linear beyond δ. Calls abs.

mean( ½d² if |d| ≤ δ else δ(|d| − ½δ) ), d = y − t

Signature

huber(y: f64[n], t: f64[n], delta: f64[]) → f64[]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks a call to another library function; select it to open that function.

deltaf64[]yf64[n]tf64[n]0.5MultiplyhdSubtractdabsadMultiplyddGreaterfarSubtractexMultiplyquadMultiplylinWherepieceMeanllf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference np.mean(np.where(|d| <= delta, 0.5*d**2, delta*(|d| - 0.5*delta))) in exact rational arithmetic, on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 24% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
73%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
1.19

Identity

Calls
Called by
—
sha256:09e7f932f09315129a5626bf600bdb7e3ff10d3f7c28bba956b661771e43c974

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.