Skip to content
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

Merged
merged 17 commits into from
Jul 13, 2021
Merged

Conversation

akapet00
Copy link
Member

Resolving #46.

@akapet00 akapet00 requested a review from mstimberg July 8, 2021 15:29
Copy link
Member

@mstimberg mstimberg left a 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.

t = self.theta
else:
raise AttributeError('Provide sampled prior or call '
'``infere_step``method first.')
Copy link
Member

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.

Copy link
Member Author

@akapet00 akapet00 Jul 10, 2021

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?

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']:
Copy link
Member

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?

if loaded.files == ['theta', 'x'] or loaded.files == ['x', 'theta']:
theta = loaded['theta']
x = loaded['x']
elif loaded.files == ['arr_0', 'arr_1']:
Copy link
Member

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?

Copy link
Member Author

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.

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,
Copy link
Member

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)?

Copy link
Member Author

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.

@mstimberg mstimberg merged commit be3209e into sbi_support Jul 13, 2021
@mstimberg mstimberg deleted the add_store_load_functionality branch July 13, 2021 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants