MCPcopy Create free account
hub / github.com/MichSchli/AVeriTeC / training_step

Method training_step

models/NaiveSeqClassModule.py:41–58  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

39 return optimizer
40
41 def training_step(self, batch, batch_idx):
42 x, x_mask, y = batch
43
44 outputs = self(x, attention_mask=x_mask, labels=y)
45 logits = outputs.logits
46 loss = outputs.loss
47
48 #cross_entropy = torch.nn.CrossEntropyLoss()
49 #loss = cross_entropy(logits, y)
50
51 preds = torch.argmax(logits, axis=1)
52
53 self.train_acc(preds.cpu(), y.cpu())
54 self.train_f1(preds.cpu(), y.cpu())
55
56 self.log("train_loss", loss)
57
58 return {'loss': loss}
59
60 def training_epoch_end(self, outs):
61 self.log('train_acc_epoch', self.train_acc)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected