MCPcopy Index your code
hub / github.com/pytorch/pytorch / AddGradientOperators

Method AddGradientOperators

caffe2/python/model_helper.py:309–331  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

307 return dbreader
308
309 def AddGradientOperators(self, *args, **kwargs):
310 if self.gradient_ops_added:
311 raise RuntimeError("You cannot run AddGradientOperators twice.")
312 self.Validate()
313
314 self.gradient_ops_added = True
315 self.grad_map = self.net.AddGradientOperators(*args, **kwargs)
316 self.param_to_grad = self.get_param_to_grad(self.params)
317
318 # Populate ParameterInfo for all parameters if missing
319 # and add gradient blob information. So optimizers can use it
320 for param, grad in self.param_to_grad.items():
321 param_info = self.get_param_info(param)
322 if param_info:
323 param_info.grad = grad
324 else:
325 self._parameters_info[param] = parameter_info.ParameterInfo(
326 param_id=None,
327 param=param,
328 grad=grad,
329 )
330
331 return self.grad_map
332
333 def get_param_to_grad(self, params):
334 '''

Callers 15

test_weight_decayMethod · 0.95
_MiniAlexNetNoDropoutMethod · 0.95
create_modelFunction · 0.95
test_dag_net_forkingMethod · 0.95
test_simple_memongerMethod · 0.95
test_fast_memongerMethod · 0.95
test_gradient_optimMethod · 0.95

Calls 4

ValidateMethod · 0.95
get_param_to_gradMethod · 0.95
get_param_infoMethod · 0.95
itemsMethod · 0.45

Tested by 15

test_weight_decayMethod · 0.76
_MiniAlexNetNoDropoutMethod · 0.76
test_dag_net_forkingMethod · 0.76
test_simple_memongerMethod · 0.76
test_fast_memongerMethod · 0.76
test_gradient_optimMethod · 0.76