gradient-descent ( X y params lr n-iters -- history params )


Vocabulary
tensors.demos.private

Inputs
Xan object
yan object
paramsan object
lran object
n-itersan object


Outputs
historyan object
paramsan object


Definition


:: gradient-descent
( X y params lr n-iters -- history params )
lr y shape>> first / :> batch-lr
{ n-iters } zeros :> history X transpose :> X-T params
n-iters [
swap dup :> old-params batch-lr X-T X old-params matmul
y t- matmul t* t-
:> new-params X y new-params compute-cost
swap history set-nth new-params
] each-integer history swap ;