-
Notifications
You must be signed in to change notification settings - Fork 76
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
Improve predictive samples #95
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.
Looks good to me! See comments below for nit questions.
laplace/baselaplace.py
Outdated
@@ -525,6 +534,10 @@ def __call__(self, x, pred_type='glm', link_approx='probit', n_samples=100): | |||
|
|||
if link_approx not in ['mc', 'probit', 'bridge']: | |||
raise ValueError(f'Unsupported link approximation {link_approx}.') | |||
|
|||
if generator is not None: | |||
if type(generator) is not torch.Generator or generator.device != x.device: |
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.
Why not just use not isinstance(generator, torch.Generator)
?
|
||
|
||
def test_diagonal_normal_samples(): |
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.
Is it possible to test against torch Normal
/MultivariateNormal
samples by using the same generator state or is the implementation not the same?
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.
Checked it, unfortunately not. But the statistics match when taking many samples.
Addresses #93 and #91 with following changes:
torch.Generator
(Smooth samples #91)