megengine.amp.GradScaler.backward¶
- GradScaler.backward(gm, y=None, dy=None, *, unscale_grad=True, update_scale='if_unscale_grad')[源代码]¶
A wrapper of GradManager’s
backward
, used to scaley
’s grad and unscale parameters’ grads.- 参数
gm (
GradManager
) – The to be wrapped GradManager.y (
Union
[Tensor
,List
[Tensor
],None
]) – Same as GradManager backward’sy
.dy (
Union
[Tensor
,List
[Tensor
],None
]) – Same as GradManager backward’sdy
. Will be multiplied byscale_factor
.unscale_grad (
bool
) – Whether dounscale
at the same time. Could beFalse
if needs to accumulate grads.update_scale (
bool
) – Same asunscale
’supdate
. Will be ignored ifunscale_grad
isFalse
.