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

Enhance posterior viz #58

Merged
merged 10 commits into from Aug 5, 2021
Merged

Enhance posterior viz #58

merged 10 commits into from Aug 5, 2021

Conversation

akapet00
Copy link
Member

@akapet00 akapet00 commented Jul 20, 2021

Resolves #51

Added method conditional_pairplot and conditional_corrcoeff to Inferencer class, which are basically thin wrappers around sbi.analysis.plot.conditional_pairplot and sbi.analysis.conditional_corrcoeff, respectively.

Also features are now optional argument, if features are not provided, the density estimator will employ a MLP by default in order to automatically extract features from high-D data.

@akapet00 akapet00 requested a review from mstimberg July 20, 2021 15:06
@akapet00 akapet00 added this to In progress in sbi integration (GSoC 2021) via automation Jul 20, 2021
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.

I made a few comments. In general, I think I'd prefer a less "thin" wrapper, i.e. make the API more like brian2modelfitting (use dictionaries with parameter names and quantities) than sbi (use PyTorch tensors). Also, maybe add example calls for these functions somewhere, e.g. in the advanced sbi example?
But if this PR keeps you from advancing, feel free to merge it as it is and we can deal with these details later.

try:
d = self.posterior
except AttributeError as e:
print(e, '\nDensity is not available.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should rather be something like

raise AttributeError('Density is not available.') from e

instead of print + raise


Parameters
----------
condition : torch.tensor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rest of the code we tried to avoid that the user has to deal with pytorch tensors themselves. Maybe this could be something like a dictionary mapping parameter names to values (like the parameters in generate, for example)? But then this should be probably what sample returns as well...

condition : torch.tensor
Condition that all but the one/two regarded parameters are
fixed to.
limits : list or torch.tensor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we make this optional and reuse the bounds here?

Comment on lines 967 to 971
condition : torch.tensor
Condition that all but the one/two regarded parameters are
fixed to.
limits : list or torch.tensor
Limits in between which each parameter will be evaulated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remarks as above.

@akapet00
Copy link
Member Author

akapet00 commented Aug 5, 2021

All your comments are taken into account. As we discuss, I will merge this to sbi_support branch because there are a few changes in API that are needed to continue the work. So just to avoid possible merge conflicts afterwards.

@akapet00 akapet00 merged commit 2762001 into sbi_support Aug 5, 2021
sbi integration (GSoC 2021) automation moved this from In progress to Done Aug 5, 2021
@akapet00 akapet00 deleted the enhance_posterior_viz branch August 5, 2021 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants