(self, batch, batch_idx)
| 35 | return loss |
| 36 | |
| 37 | def validation_step(self, batch, batch_idx): |
| 38 | images, _, labels, _ = batch |
| 39 | loss, output = self.common_step(batch, batch_idx) |
| 40 | |
| 41 | prec1 = top_k_accuracy_score(labels.cpu(), output.cpu(), labels=np.arange(output.shape[1]), k=1) |
| 42 | acc = accuracy_score(y_true=labels.cpu(), y_pred=output.argmax(1).cpu()) # should be same as prec1 |
| 43 | prec3 = top_k_accuracy_score(labels.cpu(), output.cpu(), labels=np.arange(output.shape[1]), k=3) |
| 44 | |
| 45 | self.log("val_prec1", prec1) |
| 46 | self.log("val_acc", acc) |
| 47 | self.log("val_prec3", prec3) |
| 48 | self.log("val_loss", loss) |
| 49 | return loss |
| 50 | |
| 51 | def test_step(self, batch, batch_idx): |
| 52 | return self.common_step(batch, batch_idx) |
nothing calls this directly
no test coverage detected