Skip to content

Zuko density estimators - #1068

Closed
anastasiakrouglova wants to merge 19 commits into
sbi-dev:mainfrom
bkmi:zuko_density_estimators
Closed

anastasiakrouglova wants to merge 19 commits into
sbi-dev:mainfrom
bkmi:zuko_density_estimators

Conversation

@anastasiakrouglova

@anastasiakrouglova anastasiakrouglova commented Mar 20, 2024 •

Copy link
Copy Markdown
Collaborator

What does this implement/fix? Explain your changes

We implemented the Zuko density estimators (i.e., NICE, (MAF), NSF, NCSF, SOSPF, NAF, UNAF, CNF, GF, BPF) described in https://github.com/probabilists/zuko/tree/master. The only flow that is not implemented yet, is the Gaussian Mixture Model (GMM).

Does this close any currently open issues?

Fixes #974
However, the implementation of Zuko GMM is still required.

Any relevant code examples, logs, error output, etc?

Any other comments?

For Zuko GMM, please adjust this file:zuko_flow_GMM.py and add a build_zuko_gmm function to flow.py.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.

  • I have read and understood the contribution
    guidelines
  • I agree with re-licensing my contribution from AGPLv3 to Apache-2.0.
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have reported how long the new tests run and potentially marked them
    with pytest.mark.slow.
  • New and existing unit tests pass locally with my changes
  • I performed linting and formatting as described in the contribution
    guidelines
  • I rebased on main (or there are no conflicts with main)

@gmoss13 gmoss13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work, thanks a lot @bkmi and @anastasiakrouglova! I left comments throughout, happy to discuss more.

I also see that we pyright tests are still failing - do you have the pre-commit hooks installed? if this issue is resolved and tests pass I think this PR is already quite close!

Comment thread tutorials/00_getting_started.ipynb Resolved
Comment thread tutorials/05_embedding_net.ipynb Resolved
Comment thread pyproject.toml Resolved
Comment thread sbi/neural_nets/mdn.py Resolved
Comment thread sbi/neural_nets/factory.py Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is the difference between the new class ZukoFlowGMM here and the existing ZukoFlow class? To me it looks the same, but let me know if I am missing the point. I think it makes sense to have a ZukoGMM class that can be compatible with methods that specifically require MDNs, such as SNPE-A and SNPE-C with non-atomic loss, but I think this would require more work. See #1042 (@jnsbck is working on this I believe).

Comment thread tests/density_estimator_test.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
@Baschdl

Baschdl commented Mar 21, 2024

Copy link
Copy Markdown
Contributor

Regarding pyright: four of the errors it shows are stuff which should be fixed. I'm not sure what the best way of handling Argument of type "tuple[Any, AffineTransform | Unconditional] | Any" cannot be assigned to parameter "transform" of type "LazyTransform | Sequence[LazyTransform]" is. There is an issue for it: #1074

@gmoss13 Pyright is not part of the precommit hooks.

@codecov

codecov Bot commented Mar 22, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 68.21705% with 41 lines in your changes are missing coverage. Please review.

Project coverage is 76.86%. Comparing base (4c2f71e) to head (f6afdc4).
Report is 22 commits behind head on main.

Files Patch % Lines
sbi/neural_nets/factory.py 0.00% 38 Missing ⚠️
sbi/neural_nets/density_estimators/zuko_flow.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1068      +/-   ##
==========================================
+ Coverage   76.37%   76.86%   +0.49%     
==========================================
  Files          84       89       +5     
  Lines        6507     6632     +125     
==========================================
+ Hits         4970     5098     +128     
+ Misses       1537     1534       -3     
Flag Coverage Δ
unittests 76.86% <68.21%> (+0.49%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
@gmoss13 gmoss13 mentioned this pull request Mar 24, 2024
7 of 8 tasks
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.

Add interface for Zuko density estimators 🔥

8 participants