def NLL

bendtorch@1.3.0.0 · main.bend:3305

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base
import bend-ml-tensor-array@0.1.18.0/main.bend as TA

3305# negative log-likelihood of log-probabilities (PyTorch's F.nll_loss, mean over the rows)
3306def NLL(+n: Nat, +c: Nat, logp: TA.Mat<n, c>, labels: List<&2, Nat>) -> LossOut<TA.Mat<n, c>>:
3307  match logp:
3308    case TA.Mat{lp}:
3309      nll_fin(c, n, nll_rows(n, labels, 0, c, F32.neg((1.0 / F32.from_nat(n) : F32)), NS{lp, zeros_a(Nat.mul(n, c)), 0.0}))

Uses (13)

Used by (0)

No other definition uses this definition.