TensorBackward.cross_entropy: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward Lines 1658-1667 of bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&start_line=1658&end_line=1667 import Base # Records cross_entropy(a, targets), PyTorch's cross_entropy with class # indices and mean reduction, a rank-0 tensor, from a copy of a's value: a # must be [rows, columns] logits and `targets` one class below `columns` # per row. The log_softmax lp and the one-hot rows of the targets are saved # for the VJP. Logits of another rank are refused with NotLogits (107), # targets that do not fit with TargetOutOfRange (108), an unknown id with # UnknownNode; the tape comes back unchanged. def cross_entropy(tape: Tape, +a: Nat, +targets: List<&2, U32>) -> Tape & Result<&2, &2, Error, Nat>: Tape{entries} = tape entropy_found(a, targets, value_counted(a, counted(entries))) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Error https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Tape https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=counted https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=entropy_found https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=value_counted