cross_entropy_labels

std.loss.cross_entropy_labels · Level L3

Softmax cross-entropy over rows of logits with integer labels, the way classifiers are trained: a stable log-softmax per row, then nll_labels.

−(1/n)·Σᵢ (zᵢ,yᵢ − log Σⱼ e^zᵢⱼ)

Signature

cross_entropy_labels(logits: f64[n, c], labels: i64[n]) → f64[]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

logitsf64[n, c]labelsi64[n]ReduceMaxmSubtractzExpeReduceSumsLoglseSubtractlogpnll_labelscecef64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference mean over rows of (logsumexp(z_i) - z_i[y_i]) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 12% 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
90%
largest error, in units in the last place
1.24

Identity

Calls
Called by
—
sha256:eeaceb8338df67d67eea7403d51707ffbb1c5cfab1cc0697c6f418235d7f1479

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

Control handle

Symbol
Ω:std.loss.cross_entropy_labels · Ω:cross_entropy_labels
Pins
sha256:de89b47c9fe86115742db5f27da2499fdfbca1eba6ced8d5520b5e514c234d61this graph and the 1 it reaches through calls
Evidence
sha256:d11d1c92f5639f0cd3f4bf2243386eef93c6b0901aff42a14b349b6531de6a37the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.