MCPcopy Index your code
hub / github.com/shiyu-coder/Kronos / backward

Method backward

model/module.py:27–32  ·  view source on GitHub ↗
(ctx, grad_output)

Source from the content-addressed store, hash-verified

25
26 @staticmethod
27 def backward(ctx, grad_output):
28 zq, zi, prob = ctx.saved_tensors
29 grad_array = -grad_output * (torch.log(prob) + 1) / zi.numel() / ctx.K
30 reord_grad = grad_array[zi.flatten()].reshape(zi.shape)
31 grad_input = reord_grad.unsqueeze(-1) * zq
32 return grad_input, None, None, None, None
33
34
35def codebook_entropy(zq, basis, K, eps=1e-4):

Callers 4

train_tokenizerFunction · 0.80
train_modelFunction · 0.80
train_modelFunction · 0.80
train_modelFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected