-
Notifications
You must be signed in to change notification settings - Fork 563
Fix training status of noise model of HeteroskedasticNoise
after exceptions
#2382
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
Conversation
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 for the PR. This makes sense to me! Though I think the unit test needs updating.
|
||
|
||
class TestNoiseModels(unittest.TestCase): | ||
def test_heteroskedasticnoise_error(self): |
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.
Looks like this is just testing the NumericallyUnstableModelExample
but not the actual code of the noise model?
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.
We are testing noise model HeteroskedasticNoise
here by wrapping it around NumericallyUnstableModelExample
. Or should I change the name of this class?
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.
The issue was that the previous code didn't actually test that things were reset back, seems to be fixed now.
|
||
|
||
class TestNoiseModels(unittest.TestCase): | ||
def test_heteroskedasticnoise_error(self): |
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.
The issue was that the previous code didn't actually test that things were reset back, seems to be fixed now.
In the current implementation of
HeteroskedasticNoise.forward
,self.noise_model.train(training)
is set after the output fromself.noise_model
is received. When an exception is thrown byself.noise_model()
, this reset is not called, leavingself.noise_model
in evaluation mode. This patch fixes this scenario by adding a try-finally block.The following is a typical error example:
We also believe it resolves pytorch/botorch#1386 (replicated pytorch/botorch#1386 (comment) and our patch successfully fixed it).