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

Method zero_grad

imperative/python/megengine/optimizer/optimizer.py:173–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

171
172 @deprecated(version="1.0", reason="use clear_grad instead")
173 def zero_grad(self):
174 for param_group in self.param_groups:
175 for param in param_group["params"]:
176 if param.grad is not None:
177 param.grad.reset_zero()
178
179 def clear_grad(self):
180 r"""Set the grad attribute to None for all parameters."""

Callers

nothing calls this directly

Calls 1

reset_zeroMethod · 0.80

Tested by

no test coverage detected