MCPcopy Index your code
hub / github.com/OpenMOSS/MOSS / update

Method update

finetune_moss.py:138–145  ·  view source on GitHub ↗
(self, logits, labels, loss)

Source from the content-addressed store, hash-verified

136 return self.update(logits, labels, loss)
137
138 def update(self, logits, labels, loss):
139 self.n_step += 1
140 with torch.no_grad():
141 shift_preds = logits[..., :-1, :].argmax(dim=-1)
142 shift_labels = labels[..., 1:]
143 self.right += (shift_preds == shift_labels).masked_fill(shift_labels.eq(-100), 0).sum().item()
144 self.total += (shift_labels != -100).sum().item()
145 self.total_loss += loss.item()
146
147 def get_metric(self, reset=True):
148 dist.all_reduce(self.right, op=torch.distributed.ReduceOp.SUM)

Callers 3

__call__Method · 0.95
reset_user_inputFunction · 0.80
find_layersFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected