MCPcopy Index your code
hub / github.com/openai/guided-diffusion / zero_grad

Function zero_grad

guided_diffusion/fp16_util.py:133–138  ·  view source on GitHub ↗
(model_params)

Source from the content-addressed store, hash-verified

131
132
133def zero_grad(model_params):
134 for param in model_params:
135 # Taken from https://pytorch.org/docs/stable/_modules/torch/optim/optimizer.html#Optimizer.add_param_group
136 if param.grad is not None:
137 param.grad.detach_()
138 param.grad.zero_()
139
140
141def param_grad_or_zeros(param):

Callers 1

zero_gradMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected