Bendtorch.adam_l: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/main.bend as Bendtorch Lines 285-295 of bendtorch@1.3.0.0/main.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/main.bend&start_line=285&end_line=295 import Base def adam_l(nleft: Nat, +t: U32, +lr: F32, +c1: F32, +b2: F32, +c2: F32, +eps: F32, +wd: F32, +dec: Bool, +step: F32, +bc2: F32, rw: Array & F32, rg: Array & F32, rm: Array & F32, rv: Array & F32) -> Q4: match nleft rw rg rm rv: case 0n Tuple{w, x} Tuple{g, y} Tuple{m, a} Tuple{v, b}: Q4{w, g, m, v} case 1n+p Tuple{w, +x} Tuple{g, +y} Tuple{m, +a} Tuple{v, +b}: +gg = adam_grad(dec, wd, x, y) +nm = adam_m(c1, a, gg) +nv = adam_v(b2, c2, b, gg) +nw = adam_w(step, bc2, eps, adam_decay(dec, lr, wd, x), nm, nv) +u = (t + 1 : U32) adam_l(p, u, lr, c1, b2, c2, eps, wd, dec, step, bc2, Array.get(F32, Array.set(F32, w, t, nw), u), Array.get(F32, Array.set(F32, g, t, 0.0), u), Array.get(F32, Array.set(F32, m, t, nm), u), Array.get(F32, Array.set(F32, v, t, nv), u)) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.set https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 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=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Q4 https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_decay https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_grad https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_m https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_v https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_w