def ce_summed
bendtorch-core@0.1.0.0 · src/autograd/loss.bend:341
import bendtorch-core@0.1.0.0/src/autograd/loss.bend as Loss
import Base
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import bendtorch-core@0.1.0.0/src/autograd/reduce.bend as Reduce
341def ce_summed(+rows: Nat, onehot: Core.Dynamic, shifted: Core.Dynamic, pair: Core.Dynamic & Result<&2, &1, Reduce.Error, Core.Dynamic>,
342 zero: Result<&2, &1, Core.Error, Core.Tensor<Reduction.scalar_shape()>>) -> Result<&2, &1, Error, Recorded>:
343 (exps, result) = pair
344 match result zero:
345 case Fail{error} zero:
346 Fail{ReduceError{error}}
347 case Done{sums} Fail{error}:
348 Fail{TensorError{error}}
349 case Done{sums} Done{tensor}:
350 ce_lse(rows, onehot, shifted,
351 quotient(Elementwise.binary(Elementwise.LogLeft{}, sums, Core.pack(Reduction.scalar_shape(), tensor))))