MCPcopy Create free account
hub / github.com/pytorch/tutorials / update_param

Function update_param

recipes_source/foreach_map.py:90–95  ·  view source on GitHub ↗
(param, step, exp_avg, exp_avg_sq, beta1, beta2, lr, eps)

Source from the content-addressed store, hash-verified

88 return exp_avg_sq.mul(beta2).addcmul(grad, grad, value=1 - beta2)
89
90def update_param(param, step, exp_avg, exp_avg_sq, beta1, beta2, lr, eps):
91 bias_correction1 = 1 - torch.pow(beta1, step)
92 bias_correction2 = (1 - torch.pow(beta2, step)).sqrt()
93 step_size = (lr / bias_correction1).neg()
94 denom = (exp_avg_sq.sqrt() / (bias_correction2 * step_size)).add(eps / step_size)
95 return torch.add(param, torch.div(exp_avg, denom))
96
97# Our full Adam implementation
98def foreach_map_adam(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected