MCPcopy Create free account
hub / github.com/pytorch/pytorch / get_param_to_grad

Method get_param_to_grad

caffe2/python/model_helper.py:333–347  ·  view source on GitHub ↗

Given a list of parameters returns a dict from a parameter to a corresponding gradient

(self, params)

Source from the content-addressed store, hash-verified

331 return self.grad_map
332
333 def get_param_to_grad(self, params):
334 '''
335 Given a list of parameters returns a dict from a parameter
336 to a corresponding gradient
337 '''
338
339 param_to_grad = {}
340 if not self.gradient_ops_added:
341 raise RuntimeError("You need to run AddGradientOperators first.")
342 # We need to use empty namescope when creating the gradients
343 # to prevent duplicating the namescope prefix for gradient blobs.
344 for p in params:
345 if str(p) in self.grad_map:
346 param_to_grad[p] = self.grad_map[str(p)]
347 return param_to_grad
348
349 def GetOptimizationParamInfo(self, params=None):
350 '''

Callers 2

AddGradientOperatorsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected