(self, val_iter: ValDataLoaderIter, non_blocking_transfer: bool = True)
| 429 | return total_loss |
| 430 | |
| 431 | def _validate(self, val_iter: ValDataLoaderIter, non_blocking_transfer: bool = True) -> float: |
| 432 | # Set model to evaluation mode and disable gradient computation |
| 433 | running_loss = 0 |
| 434 | with eval_mode(self.model): |
| 435 | for inputs, labels in val_iter: |
| 436 | # Copy data to the correct device |
| 437 | inputs, labels = copy_to_device( |
| 438 | [inputs, labels], device=self.device, non_blocking=non_blocking_transfer |
| 439 | ) |
| 440 | |
| 441 | # Forward pass and loss computation |
| 442 | outputs = self.model(inputs) |
| 443 | loss = self.criterion(outputs, labels) |
| 444 | running_loss += loss.item() * len(labels) |
| 445 | |
| 446 | return running_loss / len(val_iter.dataset) |
| 447 | |
| 448 | def get_lrs_and_losses(self, skip_start: int = 0, skip_end: int = 0) -> tuple[list, list]: |
| 449 | """Get learning rates and their corresponding losses |
no test coverage detected