Perform a single validation step on a batch of data from the validation set. :param batch: A batch of data (a tuple) containing the input tensor of images and target labels. :param batch_idx: The index of the current batch.
(self, batch: Tuple[torch.Tensor, torch.Tensor], batch_idx: int)
| 136 | pass |
| 137 | |
| 138 | def validation_step(self, batch: Tuple[torch.Tensor, torch.Tensor], batch_idx: int) -> None: |
| 139 | """Perform a single validation step on a batch of data from the validation set. |
| 140 | |
| 141 | :param batch: A batch of data (a tuple) containing the input tensor of images and target |
| 142 | labels. |
| 143 | :param batch_idx: The index of the current batch. |
| 144 | """ |
| 145 | loss, preds, targets = self.model_step(batch) |
| 146 | |
| 147 | # update and log metrics |
| 148 | self.val_loss(loss) |
| 149 | self.val_acc(preds, targets) |
| 150 | self.log("val/loss", self.val_loss, on_step=False, on_epoch=True, prog_bar=True) |
| 151 | self.log("val/acc", self.val_acc, on_step=False, on_epoch=True, prog_bar=True) |
| 152 | |
| 153 | def on_validation_epoch_end(self) -> None: |
| 154 | "Lightning hook that is called when a validation epoch ends." |
nothing calls this directly
no test coverage detected