-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add store load functionality #52
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.
All looks very good, I just added a few minor comments.
It's a shame that the example is not working better, maybe we should add another feature and/or train on more samples.
brian2modelfitting/inferencer.py
Outdated
t = self.theta | ||
else: | ||
raise AttributeError('Provide sampled prior or call ' | ||
'``infere_step``method first.') |
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.
tiny detail: I wouldn't put the restructured text formating with double backquotes into the error message (and there's a space missing).
Same thing in several other error messages.
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.
Should I do
raise AttributeError('Provide sampled prior or call '
'`infere_step` method first.')
or something like
raise AttributeError("Provide sampled prior or call "
"'infere_step' method first.")
instead?
brian2modelfitting/inferencer.py
Outdated
Consisting of sampled prior and summary statistics arrays. | ||
""" | ||
loaded = np.load(f, allow_pickle=True) | ||
if loaded.files == ['theta', 'x'] or loaded.files == ['x', 'theta']: |
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.
if set(loaded.files) == {'theta', 'x'}
maybe?
brian2modelfitting/inferencer.py
Outdated
if loaded.files == ['theta', 'x'] or loaded.files == ['x', 'theta']: | ||
theta = loaded['theta'] | ||
x = loaded['x'] | ||
elif loaded.files == ['arr_0', 'arr_1']: |
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.
Do we need to support this? Who would be storing things as arr_0
, arr_1
?
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.
Who would be storing things as arr_0, arr_1?
A crazy person 😄
Kidding, if you do not provide the keyword arguments when you store compressed arrays, numpy
will name the arrays arr_0
, arr_1
, ... by default. This will happen only if the user stores training data manually, which should not be the case because there is a method already implemented for that. So, yeah, you are right. We do not need to support that and I will remove that now.
examples/hh_sbi_advanced.py
Outdated
r'$\overline{C}_{m}$']) | ||
# ...and optionally, continue the multiround inference via ``infere`` method | ||
posterior_multi_round = inferencer.infere(n_rounds=2, | ||
theta=theta_loaded, x=x_loaded, |
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.
Shouldn't this be based on the sampled posterior instead of putting in the sampled prior data again (theta_loaded
/ x_loaded
)?
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.
Yes, my mistake. Nothing will happen by specifying theta
and x
because they are already defined inside the class. Posterior is also stored in a class variable, so you should only specify n_rounds
here.
Resolving #46.