logistic_loss

std.optim.logistic_loss · Level L5

Logistic regression's loss: the mean binary cross-entropy of the logits Xw against y, through bce_with_logits. Bind its gradient as @grad[f=std.optim.logistic_loss,wrt=w] and minimize_adam trains on the loss alone; NOVA derives the gradient by reverse mode.

L(w) = mean( bce(Xw, y) )

Signature

logistic_loss(w: f64[d], X: f64[n, d], y: f64[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.

wf64[d]Xf64[n, d]yf64[n]ReshapewcMatMulzcReshapezbce_with_logitsllf64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference mean(t·log(1 + e^(−z)) + (1 − t)·log(1 + e^z)), z = Xw to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 32% of it.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 22% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
68%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
1.25

Identity

Calls
Called by
—
sha256:3a29dc3f47e6791565fd9ecbb901649c42f7bd29fda5d63d54fa69a199d6d74b

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

Control handle

Symbol
Ω:std.optim.logistic_loss · Ω:logistic_loss
Pins
sha256:af50c553b03b6a4ec5c9f4aac87d519afb233df55f7e00aa1101ed32a43aad3athis graph and the 2 it reaches through calls
Evidence
sha256:0a7c0ca040765a82c39bb86a969927ce6f52e54f2ac1029ee7a69e53bb7f5498the 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.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.