MCPcopy Create free account
hub / github.com/BIT-MCS/DRL-eFresh / __init__

Method __init__

methods/model.py:306–312  ·  view source on GitHub ↗
(self, model, device)

Source from the content-addressed store, hash-verified

304
305class Shared_grad_buffers():
306 def __init__(self, model, device):
307 self.grads = {}
308 self.counter = Counter()
309
310 for name, p in model.named_parameters():
311 if p.requires_grad:
312 self.grads[name + '_grad'] = torch.zeros(p.size()).share_memory_().to(device)
313
314 def add_gradient(self, model):
315 self.counter.increment()

Callers

nothing calls this directly

Calls 2

CounterClass · 0.90
toMethod · 0.80

Tested by

no test coverage detected