def ce_exps
bendtorch-core@0.1.0.0 · src/autograd/loss.bend:353
import bendtorch-core@0.1.0.0/src/autograd/loss.bend as Loss
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import bendtorch-core@0.1.0.0/src/autograd/sum_to_size.bend as SumToSize
353def ce_exps(+rows: Nat, onehot: Core.Dynamic, +target: Shape.Shape, pair: (Core.Dynamic & Core.Dynamic) & Result<&2, &1, Core.Error, Core.Dynamic>) ->
354 Result<&2, &1, Error, Recorded>:
355 (operands, result) = pair
356 (shifted, zero) = operands
357 match result:
358 case Fail{error}:
359 Fail{TensorError{error}}
360 case Done{exps}:
361 ce_summed(rows, onehot, shifted, SumToSize.sum_to_size(exps, target), Core.new(Reduction.scalar_shape(), 0.0))