MCPcopy Create free account
hub / github.com/TPCD/DCCL / backward

Method backward

project_utils/cluster_memory_utils.py:21–32  ·  view source on GitHub ↗
(ctx, grad_outputs)

Source from the content-addressed store, hash-verified

19
20 @staticmethod
21 def backward(ctx, grad_outputs):
22 inputs, targets = ctx.saved_tensors
23 grad_inputs = None
24 if ctx.needs_input_grad[0]:
25 grad_inputs = grad_outputs.mm(ctx.features)
26
27 # momentum update
28 for x, y in zip(inputs, targets):
29 ctx.features[y] = ctx.momentum * ctx.features[y] + (1. - ctx.momentum) * x
30 ctx.features[y] /= ctx.features[y].norm()
31
32 return grad_inputs, None, None, None
33
34
35def cm(inputs, indexes, features, momentum=0.5, device=None):

Callers 2

trainFunction · 0.45
trainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected