Skip to content

Zuko density estimators - #1088

Merged
anastasiakrouglova merged 27 commits into
sbi-dev:974-zuko-density-estimators-interfacefrom
bkmi:zuko_density_estimators
Mar 27, 2024
Merged

anastasiakrouglova merged 27 commits into
sbi-dev:974-zuko-density-estimators-interfacefrom
bkmi:zuko_density_estimators

Conversation

@anastasiakrouglova

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 # (issue)
Fixes #974
However, the implementation of Zuko GMM is still required.

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

Any other comments?

This pull request resolve proposals Guy on Zuko integration.

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)

@Baschdl

Baschdl commented Mar 22, 2024

Copy link
Copy Markdown
Contributor

The base branch of this PR is sbi-dev:974-zuko-density-estimators-interface right now. You probably want to merge it into main. There is an option to change it.

Comment thread sbi/neural_nets/flow.py Resolved
Comment thread tutorials/05_embedding_net.ipynb Resolved
Comment thread sbi/neural_nets/factory.py Resolved
Comment thread sbi/neural_nets/factory.py Resolved
Comment thread sbi/neural_nets/factory.py Resolved
Comment thread sbi/neural_nets/factory.py Resolved


@pytest.mark.parametrize("density_estimator", (NFlowsFlow, ZukoFlow))
@pytest.mark.parametrize(

@manuelgloeckler manuelgloeckler Mar 22, 2024 •

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.

Add here the new build functions, which are not yet covered :)

@anastasiakrouglova anastasiakrouglova Mar 27, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

what do you exactly mean? I have a pytest function which does the following:

@pytest.mark.parametrize(
    "build_density_estimator",
    (
        build_maf,
        build_maf_rqs,
        build_nsf,
        build_zuko_nice,
        build_zuko_maf,
        build_zuko_nsf,
        build_zuko_ncsf,
        build_zuko_sospf,
        build_zuko_naf,
        build_zuko_unaf,
        build_zuko_cnf,
        build_zuko_gf,
        build_zuko_bpf,
    ),
)

Or is that not enough?

@manuelgloeckler manuelgloeckler 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.

Hey, great work! So many new options.

I added a few comments, which should be resolved before merging into main.

As this PR wants to merge into another branch, I will already approve it.
Feel free to merge it yourself.

Comment thread sbi/neural_nets/mdn.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread tests/density_estimator_test.py Resolved

@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.

See comments by @manuelgloeckler et al. In the meantime, let's merge this into the the sbi-dev:974 branch, and create a new PR to merge that branch into main. In the meantime, could you close PRs #1068 and #1064, if you are no longer using them? I think they might be duplicates of this PR.

@Baschdl Baschdl 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.

I copied my review from #1068. Those suggestions apply once you rebase/merge the current main into your branch. You can directly commit them with "Add suggestion to batch" and then "Commit suggestion".
Let me know if I should do this directly.

Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
Comment thread sbi/neural_nets/flow.py Resolved
@anastasiakrouglova
anastasiakrouglova merged commit bf65102 into sbi-dev:974-zuko-density-estimators-interface Mar 27, 2024
janfb added a commit that referenced this pull request Apr 5, 2024
* update zuko to 1.1.0

* test zuko_gmm commit

* build_zuko_nsf added

* add build_zuko_naf, update test

* add license change to pr template.

* CLN pyproject.toml (#1009)

* CLN pyproject.toml

* CLN optional deps comment

* CLN alphabetical order

* fix x_o and broken link tutorial 7 (#1003)

* fix x_o and broken link tutorial 7

* typo in title

* suppress plotting output

---------

Co-authored-by: Matthijs <[email protected]>

* replace prepare_for_sbi in tutorials (#1013)

* add zuko density estimators

* not working gmm

* update tests for PR

* update PR for pyright

* resolve pyright

* add reportArgumentType

* resolve pyright issue

* resolve all issues pyright

* resolve pyright

* add typing and docstring

* add functions from factory to test

* remove comment mdn file

* add docstrings flow file

* add docstring in density_estimator_test.py

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* removed pyright

---------

Co-authored-by: bkmi <[email protected]>
Co-authored-by: Nastya Krouglova <[email protected]>
Co-authored-by: Jan Boelts <[email protected]>
Co-authored-by: Thomas Moreau <[email protected]>
Co-authored-by: Matthijs Pals <[email protected]>
Co-authored-by: Matthijs <[email protected]>
Co-authored-by: zinaStef <[email protected]>
Co-authored-by: Sebastian Bischoff <[email protected]>
janfb added a commit that referenced this pull request Apr 5, 2024
* Zuko density estimators (#1088)

* update zuko to 1.1.0

* test zuko_gmm commit

* build_zuko_nsf added

* add build_zuko_naf, update test

* add license change to pr template.

* CLN pyproject.toml (#1009)

* CLN pyproject.toml

* CLN optional deps comment

* CLN alphabetical order

* fix x_o and broken link tutorial 7 (#1003)

* fix x_o and broken link tutorial 7

* typo in title

* suppress plotting output

---------

Co-authored-by: Matthijs <[email protected]>

* replace prepare_for_sbi in tutorials (#1013)

* add zuko density estimators

* not working gmm

* update tests for PR

* update PR for pyright

* resolve pyright

* add reportArgumentType

* resolve pyright issue

* resolve all issues pyright

* resolve pyright

* add typing and docstring

* add functions from factory to test

* remove comment mdn file

* add docstrings flow file

* add docstring in density_estimator_test.py

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* Update sbi/neural_nets/flow.py

Co-authored-by: Sebastian Bischoff <[email protected]>

* removed pyright

---------

Co-authored-by: bkmi <[email protected]>
Co-authored-by: Nastya Krouglova <[email protected]>
Co-authored-by: Jan Boelts <[email protected]>
Co-authored-by: Thomas Moreau <[email protected]>
Co-authored-by: Matthijs Pals <[email protected]>
Co-authored-by: Matthijs <[email protected]>
Co-authored-by: zinaStef <[email protected]>
Co-authored-by: Sebastian Bischoff <[email protected]>

* merge

* hate

* merge

* merge

* merge

* merge

* MERGE

* remove cnf

* implement changes Jan

* Update sbi/neural_nets/factory.py

Co-authored-by: Jan <[email protected]>

* resolve issues Jan

* undo changes to tutorials folder.

* sort dependencies.

---------

Co-authored-by: bkmi <[email protected]>
Co-authored-by: Nastya Krouglova <[email protected]>
Co-authored-by: Jan Boelts <[email protected]>
Co-authored-by: Thomas Moreau <[email protected]>
Co-authored-by: Matthijs Pals <[email protected]>
Co-authored-by: Matthijs <[email protected]>
Co-authored-by: zinaStef <[email protected]>
Co-authored-by: Sebastian Bischoff <[email protected]>
Co-authored-by: Jan <[email protected]>
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.