Skip to content

Commit

Permalink
fix: Fixed LR Find when loss explodes
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Nov 14, 2021
1 parent 2280ea3 commit d831c1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion holocron/trainer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,17 @@ def lr_find(

# Record
if torch.isnan(batch_loss) or torch.isinf(batch_loss):
raise ValueError("loss value is NaN or inf.")
if batch_idx == 0:
raise ValueError("loss value is NaN or inf.")
else:
break
self.loss_recorder.append(batch_loss.item())
# Stop after the number of iterations
if batch_idx + 1 == num_it:
break

self.lr_recorder = self.lr_recorder[:len(self.loss_recorder)]

def plot_recorder(self, beta: float = 0.95, block: bool = True) -> None:
"""Display the results of the LR grid search
Expand Down

0 comments on commit d831c1b

Please sign in to comment.