MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / zero_grad

Method zero_grad

imperative/python/megengine/module/module.py:386–390  ·  view source on GitHub ↗

r"""Sets all parameters' grads to zero

(self)

Source from the content-addressed store, hash-verified

384
385 @deprecated(version="1.0")
386 def zero_grad(self) -> None:
387 r"""Sets all parameters' grads to zero"""
388 for param in self.parameters():
389 if param.grad is not None:
390 param.grad.reset_zero()
391
392 def train(self, mode: bool = True, recursive: bool = True) -> None:
393 r"""Sets training mode of all the modules within this module (including itself) to

Callers

nothing calls this directly

Calls 2

parametersMethod · 0.95
reset_zeroMethod · 0.80

Tested by

no test coverage detected