Skip to content

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

Merged
gcroci2 merged 5 commits intomainfrom
hotfix_533_unboundlocalerror_gcroci2
Dec 20, 2023
Merged

fix: handle cases in which losses are nan during the training#535
gcroci2 merged 5 commits intomainfrom
hotfix_533_unboundlocalerror_gcroci2

Conversation

@gcroci2
Copy link
Copy Markdown
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
@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