MCPcopy Create free account
hub / github.com/openai/improved-diffusion / zero_grad

Function zero_grad

improved_diffusion/fp16_util.py:71–76  ·  view source on GitHub ↗
(model_params)

Source from the content-addressed store, hash-verified

69
70
71def zero_grad(model_params):
72 for param in model_params:
73 # Taken from https://pytorch.org/docs/stable/_modules/torch/optim/optimizer.html#Optimizer.add_param_group
74 if param.grad is not None:
75 param.grad.detach_()
76 param.grad.zero_()

Callers 1

forward_backwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected