-
Notifications
You must be signed in to change notification settings - Fork 206
Fix misleading assertion message in NPE train #1706
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1706 +/- ##
=======================================
Coverage ? 84.65%
=======================================
Files ? 137
Lines ? 11487
Branches ? 0
=======================================
Hits ? 9724
Misses ? 1763
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more.
|
janfb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @satwiksps ! Made one suggestion for the error message and a proposal to change to ValueError.
| "in append_simulations(), or set force_first_round_loss=True for " | ||
| "simulations drawn from the prior." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "in append_simulations(), or set force_first_round_loss=True for " | |
| "simulations drawn from the prior." | |
| "in append_simulations(), or set force_first_round_loss=True for " | |
| "simulations drawn from the prior." | |
| "Warning: Setting force_first_round_loss=True with simulations not drawn " | |
| "from the prior will produce the proposal posterior instead of the true " | |
| "posterior, which is typically more narrow." |
| self._round = max(self._data_round_index) | ||
|
|
||
| if self._round == 0 and self._neural_net is not None: | ||
| assert context.force_first_round_loss or context.resume_training, ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please exchange this assertion with a boolean check followed by a ValueError with the message below?
Issue Reference
Summary
This PR updates a misleading assertion message in the NPE training workflow. When
train()is called a second time withresume_training=Falseandforce_first_round_loss=False, the current message incorrectly states thatappend_simulations()was called again after training, even when no new simulations were appended. The updated message now reflects the two valid user stories:No new simulations appended (round 0):
Users should set
resume_training=Trueto continue training the same neural network.New simulations appended (multi-round):
Users must either pass a proposal when calling
append_simulations(), or explicitly setforce_first_round_loss=Truefor simulations drawn from the prior.Changes
sbi/inference/trainers/npe/npe_base.pywithin_get_start_index().Reproduced Output After Fix
Click to view traceback screenshot