law sgd_step_values

bendtorch-core@0.1.0.0 · src/autograd/sgd_LAWS.bend:61

import bendtorch-core@0.1.0.0/src/autograd/sgd_LAWS.bend as SgdLAWS
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward
import bendtorch-core@0.1.0.0/src/autograd/sgd.bend as Sgd

61# A parameter whose slot holds g gets p - lr * g on the parallel elementwise
62# build, in transport form: for a replayed value p and a replayed gradient g
63# whose shapes broadcast, for every P, if P holds for every result that keeps
64# the node, the shape, the saved values and g with its words, and holds a
65# value of the plan's shape whose word k is scalar(Descend{lr},
66# p[left_map(plan, k)], g[right_map(plan, k)]) (sgd_descend_scalar: p - lr *
67# g), next to Done, then P holds for the step of that parameter.
68law sgd_step_values:
69  for +lr: F32
70  for node: Backward.Node
71  for +shape: Shape.Shape
72  for saved: Backward.Saved
73  for +g_shape: Shape.Shape
74  for +plan: Shape.BroadcastPlan
75  for planned: {Shape.broadcast_checked(shape, g_shape) == Done{plan} : Result<&2, &2, Shape.Error, Shape.BroadcastPlan>}
76  for +fill: F32
77  for +ops: List<&2, StorageLaws.Op>
78  for -fits: {Lifecycle.logical_length(Replayed.storage(shape, fill, ops)) == Shape.logical_numel(Shape.dimensions(shape)) : Nat}
79  for +g_fill: F32
80  for +g_ops: List<&2, StorageLaws.Op>
81  for -g_fits: {Lifecycle.logical_length(Replayed.storage(g_shape, g_fill, g_ops)) == Shape.logical_numel(Shape.dimensions(g_shape)) : Nat}
82  for -P: Backward.Entry & Result<&2, &2, Sgd.Error, Unit> -> Type
83  for h: DescendWith(lr, node, shape, saved, plan, fill, ops, g_shape, g_fill, g_ops, P)
84  P(Sgd.descend(lr, Backward.Entry{node, shape, Core.Packed{shape, Core.TTensor{Replayed.storage(shape, fill, ops), fits}}, saved,
85    Gradient.Held{Core.Packed{g_shape, Core.TTensor{Replayed.storage(g_shape, g_fill, g_ops), g_fits}}}}))

Uses (27)

Used by (0)

No other definition uses this definition.