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

Temporary Wrappers to fix MADE #1398

Merged
merged 2 commits into from
Feb 20, 2025
Merged

Conversation

gmoss13
Copy link
Contributor

@gmoss13 gmoss13 commented Feb 20, 2025

Fixes #1394.

The fix here is to add a wrapper around MADE and MADEMoG which just initializes the networks with an additional dummy feature, and replaces the forward call of these methods by first adding a dummy input variable which gets thrown out of the output.

@gmoss13 gmoss13 linked an issue Feb 20, 2025 that may be closed by this pull request
@gmoss13 gmoss13 requested a review from janfb February 20, 2025 13:43
Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

great, thanks for adding this!

can you maybe add a simple test for this patch in general? e.g., conditional density estimation with a linear gaussian test with multiple dimensions? I think this test is missing in nflows anyways so it would be good to have this.

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 81.57895% with 7 lines in your changes missing coverage. Please review.

Project coverage is 78.13%. Comparing base (18f92b1) to head (7c7de6c).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
sbi/utils/nn_utils.py 80.55% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1398       +/-   ##
===========================================
- Coverage   89.31%   78.13%   -11.19%     
===========================================
  Files         119      119               
  Lines        8779     8891      +112     
===========================================
- Hits         7841     6947      -894     
- Misses        938     1944     +1006     
Flag Coverage Δ
unittests 78.13% <81.57%> (-11.19%) ⬇️

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

Files with missing lines Coverage Δ
sbi/neural_nets/net_builders/flow.py 93.12% <100.00%> (ø)
sbi/utils/nn_utils.py 83.01% <80.55%> (-5.22%) ⬇️

... and 39 files with indirect coverage changes

@gmoss13
Copy link
Contributor Author

gmoss13 commented Feb 20, 2025

great, thanks for adding this!

can you maybe add a simple test for this patch in general? e.g., conditional density estimation with a linear gaussian test with multiple dimensions? I think this test is missing in nflows anyways so it would be good to have this.

I added MADEMoG to the list of SNPE linear_gaussian tests (which are slow but pass locally for me), and the density_estimators tests. This is because MADEMoG is what we actually use as build_made. The custom MADEWrapper is currently not used, but is included in anticipation for #1269. In this case, it should be tests through CategoricalMADE tests.

@gmoss13 gmoss13 requested a review from janfb February 20, 2025 14:56
Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

Great! Makes sense now and the new made test nicely fails without your fix. Thanks! 🙏

@janfb janfb mentioned this pull request Feb 20, 2025
9 tasks
@janfb janfb merged commit 68ee1a7 into main Feb 20, 2025
6 checks passed
@janfb janfb deleted the 1394-custom-made-class-overwriting-nflows branch February 20, 2025 16:09
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.

Custom MADE class overwriting nflows
2 participants