def cea_grad
bend-ml-tensor-array@0.1.19.0 · main.bend:429
import bend-ml-tensor-array@0.1.19.0/main.bend as BendMlTensorArray
import Base
429
430def cea_grad(k: Nat, +idx: U32, +j: Nat, +label: Nat, +s: F32, +nf: F32, r: Array<F32> & F32) -> Array<F32>:
431 match k r:
432 case 0n Tuple{c, +x}:
433 Array.set(F32, c, idx, ((((x / s : F32) - hit(Nat.is_eq(label, j)) : F32) / nf) : F32))
434 case 1n+p Tuple{c, +x}:
435 cea_grad(p, (idx + 1 : U32), 1n+j, label, s, nf, Array.get(F32, Array.set(F32, c, idx, ((((x / s : F32) - hit(Nat.is_eq(label, j)) : F32) / nf) : F32)), (idx + 1 : U32)))