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

Balanced neural ratio estimation #779

Merged
merged 11 commits into from
Dec 16, 2022
Merged

Balanced neural ratio estimation #779

merged 11 commits into from
Dec 16, 2022

Conversation

ADelau
Copy link
Contributor

@ADelau ADelau commented Nov 8, 2022

Implement Balanced neural ratio estimation.

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Awesome, thanks a lot for this!

One small comment below, but a few additional comments:

labels[1::2] = 0.0

# Binary cross entropy to learn the likelihood (AALR-specific)
bce = nn.BCELoss()(likelihood, labels)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to not call super()._loss(theta, x)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I need access to the logits to compute the regularizer and the loss function does not return those.

Copy link
Contributor

@michaeldeistler michaeldeistler Nov 8, 2022

Choose a reason for hiding this comment

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

Makes sense, thank you!

@michaeldeistler
Copy link
Contributor

Also, please run isort ;)

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 a lot for adding this!

I added one small comment on the docs, and +1 on adding a functional test for bnre.

sbi/inference/snre/bnre.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2022

Codecov Report

Merging #779 (4aa9ed7) into main (ecdfe09) will decrease coverage by 0.09%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
- Coverage   74.51%   74.42%   -0.10%     
==========================================
  Files          77       78       +1     
  Lines        6118     6143      +25     
==========================================
+ Hits         4559     4572      +13     
- Misses       1559     1571      +12     
Flag Coverage Δ
unittests 74.42% <50.00%> (-0.10%) ⬇️

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

Impacted Files Coverage Δ
sbi/inference/snre/snre_base.py 94.87% <ø> (ø)
sbi/inference/snre/bnre.py 45.45% <45.45%> (ø)
sbi/inference/__init__.py 100.00% <100.00%> (ø)
sbi/inference/snre/__init__.py 100.00% <100.00%> (ø)
sbi/utils/user_input_checks_utils.py 90.25% <0.00%> (ø)
sbi/utils/user_input_checks.py 87.87% <0.00%> (+0.12%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Hi Arnaud,

thanks for the documentation fixes. Could you still add BNRE to the tests and make sure that they pass?

Michael

@ADelau
Copy link
Contributor Author

ADelau commented Nov 15, 2022

Hi Michael,

Yes sorry for the delay. I have not forgotten, it is my todo list and I will do it asap!

@michaeldeistler
Copy link
Contributor

michaeldeistler commented Nov 15, 2022

Great, thanks! No rush from our side!

@ADelau
Copy link
Contributor Author

ADelau commented Nov 24, 2022

Hi, I have now added the tests and updated the specifications to explain what BNRE is. I believe that I have addressed all the comments, tell me if there is something missing!

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! One of the new BNRE tests is failing, I added comments below.

tests/linearGaussian_snre_test.py Show resolved Hide resolved
@bkmi bkmi mentioned this pull request Dec 10, 2022
10 tasks
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.

Looks great, thank you for contributing Balanced NRE!

@janfb janfb merged commit ba98621 into sbi-dev:main Dec 16, 2022
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.

4 participants