(self, batch, batch_idx)
| 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) |
nothing calls this directly
no outgoing calls
no test coverage detected