bce_with_logits

std.loss.bce_with_logits · Level L5

Binary cross-entropy taken from logits: max(z, 0) − z·t + log1p(e^(−|z|)), computed as two smooth branches (z ≥ 0 and z < 0). It never forms the probability, so it stays finite and accurate where sigmoid would round to 0 or 1.

mean( max(z, 0) − z·t + log1p(e^(−|z|)) ), as two smooth branches

Signature

bce_with_logits(z: f64[n], t: 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.

tf64[n]zf64[n]0.0MultiplyztLessnegWherezpWhereznSubtractdNegatenzpExpenExpepLog1psoftnLog1psoftpWheresoftAddsMeanllf64[]
  • 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)) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 40 float64 results inside the running error bound; the closest uses 21% 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 19% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
78%
largest error, in units in the last place
1.53

Note

The reference is −t·log σ(z) − (1 − t)·log(1 − σ(z)) with each log written out as log(1 + e^(∓z)), in exact arithmetic: no 1 − σ is ever formed, so nothing cancels even at 100 digits. Since Round 14.29 the branches are separate, each fed a safe input, so reverse mode gives (σ(z) − t)/n everywhere; the earlier graph had the same values bit for bit but gave (1 − t)/n at z = 0.

Identity

Calls
—
Called by
sha256:4bd8f16a45a337d1f9ae76d8f336847a31e5bd497b7cf9351230c29b9f48b30f

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

Control handle

Symbol
Ω:std.loss.bce_with_logits · Ω:bce_with_logits
Pins
sha256:3afa05d82a96b6325ee43b0bfeb2c0e07c08b07423f7062a93ff8530fdb27000this graph alone
Evidence
sha256:0c7f547a00bbe40efe3dd99dcc3114a73ee7f4b233f331e6546938c19d2accc0the 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.