Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle cases in which losses are nan during the training #535

Merged
merged 5 commits into from
Dec 20, 2023

Conversation

gcroci2
Copy link
Collaborator

@gcroci2 gcroci2 commented Dec 19, 2023

During the training (in the trainer.Trainer.train() method), if the loss is nan (such as when using very few datapoints, like in #528), checkpoint_model is never created, thus the crashes and gives the following error:

UnboundLocalError: local variable 'checkpoint_model' referenced before assignment

This PR adds checks for handling such cases and integration tests.

  • I used tmpdir_factory fixture for generating the hdf5 files needed for the checks only once per tests' session.
  • I used pytest.mark.parametrize for passing in multiple inputs to the test function.

@gcroci2 gcroci2 merged commit f9681aa into main Dec 20, 2023
6 checks passed
@gcroci2 gcroci2 deleted the hotfix_533_unboundlocalerror_gcroci2 branch December 20, 2023 15:39
@gcroci2 gcroci2 added the JOSS label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix UnboundLocalError: local variable 'checkpoint_model' referenced before assignment
1 participant