LAWS.seq_chain: law of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/LAWS.bend as LAWS Lines 35-46 of bendtorch@1.3.0.0/LAWS.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/LAWS.bend&start_line=35&end_line=46 import Base import bendtorch@1.3.0.0/main.bend as T import bendtorch@1.3.0.0/spec.bend as Spec # LAW (seq_chain): T.Seq's own code, running two linear layers of the exact model one after the other, gives a backward # pass that is the adjoint of its forward pass: dy·y == dx·x, for the y the forward pass returns and the dx its backward # pass returns from the state the forward pass saved. adjoint_seq says it of the formulas; this says it of the # combinator that composes the layers: Seq feeds the second layer's input gradient to the first, the chain rule. law seq_chain: for +w1: List<&2, List<&2, Nat>> for +w2: List<&2, List<&2, Nat>> for +x: List<&2, Nat> for +dy: List<&2, Nat> for g1: List<&2, List<&2, Nat>> for g2: List<&2, List<&2, Nat>> {Spec.dotn(dy, Spec.fy(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, T.Two, List<&2, Nat>>, T.Layer.fwd(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, List<&2, Nat>, T.Two, List<&2, Nat>>, Spec.SeqL(), T.Two{w1, w2}, x))) == Spec.dotn(Spec.bdx(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, T.Layer.bwd(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, List<&2, Nat>, T.Two, List<&2, Nat>>, Spec.SeqL(), T.Two{w1, w2}, Spec.fsv(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, T.Two, List<&2, Nat>>, T.Layer.fwd(T.Two>, List<&2, List<&2, Nat>>>, List<&2, Nat>, List<&2, Nat>, T.Two, List<&2, Nat>>, Spec.SeqL(), T.Two{w1, w2}, x)), dy, T.Two{g1, g2})), x) : Nat} Uses (11): 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=bendtorch@1.3.0.0/LAWS.bend&name=adjoint_seq https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Layer.bwd https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Layer.fwd https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Two https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=SeqL https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=bdx https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=dotn https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=fsv https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=fy