Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions autoPyTorch/pipeline/components/training/trainer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ def _fit(self, X: Dict[str, Any], y: Any = None, **kwargs: Any) -> 'TrainerChoic
writer=writer,
)

# its fine if train_loss is None due to `is_max_time_reached()`
if train_loss is None:
if self.budget_tracker.is_max_time_reached():
break
else:
raise RuntimeError("`train_loss` computed to None.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise RuntimeError("`train_loss` computed to None.")
raise RuntimeError("Got an unexpected None in `train_loss`.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well, please add a simple test.


val_loss, val_metrics, test_loss, test_metrics = None, {}, None, {}
if self.eval_valid_each_epoch(X):
val_loss, val_metrics = self.choice.evaluate(X['val_data_loader'], epoch, writer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _scheduler_step(

def train_epoch(self, train_loader: torch.utils.data.DataLoader, epoch: int,
writer: Optional[SummaryWriter],
) -> Tuple[float, Dict[str, float]]:
) -> Tuple[Optional[float], Dict[str, float]]:
"""
Train the model for a single epoch.

Expand Down Expand Up @@ -317,6 +317,9 @@ def train_epoch(self, train_loader: torch.utils.data.DataLoader, epoch: int,
epoch * len(train_loader) + step,
)

if N == 0:
return None, {}
Comment on lines +330 to +331

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a simple test?


self._scheduler_step(step_interval=StepIntervalUnit.epoch, loss=loss_sum / N)

if self.metrics_during_training:
Expand Down