Skip to content

Commit

Permalink
make lr finder error message more helpful.
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed Dec 4, 2023
1 parent 514e2f8 commit b349bb0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ignite/handlers/lr_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ def _log_lr_and_loss(self, trainer: Engine, output_transform: Callable, smooth_f
raise ValueError(
"if output of the engine is torch.Tensor, then "
"it must be 0d torch.Tensor or 1d torch.Tensor with 1 element, "
f"but got torch.Tensor of shape {loss.shape}"
f"but got torch.Tensor of shape {loss.shape}."
"You may wish to use the output_transform kwarg with the attach method e.g.\n"
"""
lr_finder = FastaiLRFinder()
with lr_finder.attach(trainer, output_transform=lambda x:x["train_loss"]) as trainer_with_lr_finder:
trainer_with_lr_finder.run(dataloader_train)
"""
)
else:
raise TypeError(
Expand Down

0 comments on commit b349bb0

Please sign in to comment.