def descend_at
bendtorch-core@0.1.0.0 · src/autograd/sgd.bend:127
import bendtorch-core@0.1.0.0/src/autograd/sgd.bend as Sgd
import Base
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward
127
128
129def descend_at(+lr: F32, entries: List<&1, Backward.Entry>, +count: Nat, +id: Nat, same: Bool) -> Walked():
130 match entries count same:
131 case Nil{} count same:
132 (Nil{}, Fail{UnknownNode{}})
133 case Con{entry, rest} 0n same:
134 (entry <> rest, Fail{UnknownNode{}})
135 case Con{entry, rest} 1n+below True{}:
136 placed(rest, descend(lr, entry))
137 case Con{entry, rest} 1n+below False{}:
138 kept(entry, descend_at(lr, rest, below, id, Backward.at_head(below, id)))