Skip to content

move all inference methods into trainers folder - #1238

Merged
janfb merged 7 commits into
mainfrom
trainers
Aug 27, 2024
Merged

janfb merged 7 commits into
mainfrom
trainers

Conversation

@michaeldeistler

@michaeldeistler michaeldeistler commented Aug 27, 2024 •

Copy link
Copy Markdown
Contributor

File structure

Screenshot 2024-08-28 at 08 19 27

Renaming of inference classes

Breaking change! The following will no longer work:

from sbi.inference.snpe import SNPE_C

It is now:

from sbi.inference.trainers.npe import NPE_C  # or `... import SNPE_C`

We are raising an explicit error here. For this, I created a dummy sbi/inference/snpe/__init__.py. We can remove this in a future release.

If users directly import from sbi.inference then all is good.

TODO

I still have to update all tutorials and tests to use NPE names instead of SNPE. However, this is strictly optional because the aliases work well. To demonstrate that the aliases work, I would prefer to merge this PR before changing tests and tutorials, and then make a separate PR.

@michaeldeistler
michaeldeistler requested a review from janfb August 27, 2024 16:10
@codecov

codecov Bot commented Aug 27, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.08197% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.16%. Comparing base (3b9be6a) to head (8624c07).
Report is 1 commits behind head on main.

Files Patch % Lines
sbi/inference/snle/__init__.py 0.00% 1 Missing ⚠️
sbi/inference/snpe/__init__.py 0.00% 1 Missing ⚠️
sbi/inference/snre/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1238      +/-   ##
==========================================
- Coverage   86.08%   78.16%   -7.93%     
==========================================
  Files         114      117       +3     
  Lines        8662     8679      +17     
==========================================
- Hits         7457     6784     -673     
- Misses       1205     1895     +690     
Flag Coverage Δ
unittests 78.16% <95.08%> (-7.93%) ⬇️

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

Files Coverage Δ
sbi/inference/__init__.py 100.00% <100.00%> (ø)
sbi/inference/posteriors/__init__.py 100.00% <100.00%> (ø)
sbi/inference/trainers/base.py 86.91% <ø> (ø)
sbi/inference/trainers/fmpe/__init__.py 100.00% <100.00%> (ø)
sbi/inference/trainers/fmpe/fmpe.py 94.33% <100.00%> (ø)
sbi/inference/trainers/nle/__init__.py 100.00% <100.00%> (ø)
sbi/inference/trainers/nle/mnle.py 85.36% <100.00%> (ø)
sbi/inference/trainers/nle/nle_a.py 100.00% <100.00%> (ø)
sbi/inference/trainers/nle/nle_base.py 93.93% <100.00%> (ø)
sbi/inference/trainers/npe/__init__.py 100.00% <100.00%> (ø)
... and 15 more

... and 23 files with indirect coverage changes

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

This is great! I added some comments and found one typo 🧐

Comment thread sbi/inference/__init__.py Resolved
Comment thread sbi/inference/__init__.py Resolved
Comment thread sbi/inference/snle/__init__.py Resolved
Comment thread sbi/inference/trainers/npe/npe_c.py Resolved
Comment thread sbi/inference/trainers/npe/npe_c.py Resolved
@michaeldeistler
michaeldeistler requested a review from janfb August 27, 2024 19:01

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

Looks great! Thanks 🙏

Comment thread sbi/inference/__init__.py Resolved
@janfb
janfb merged commit b46c7c5 into main Aug 27, 2024
@janfb
janfb deleted the trainers branch August 27, 2024 20:17
@janfb janfb linked an issue Aug 27, 2024 that may be closed by this pull request
2 tasks done
@janfb janfb mentioned this pull request Aug 27, 2024
2 tasks done
michaeldeistler added a commit that referenced this pull request Aug 28, 2024
* move all inference methods into `trainers` folder

* remove the "S" from all inference methods

* Rename FMPE

* All imports are fixed now

* Add dummy files to snpe/snre/snle folders to raise an explicit error

* formatting

* feedback from review
michaeldeistler added a commit that referenced this pull request Aug 28, 2024
* move all inference methods into `trainers` folder

* remove the "S" from all inference methods

* Rename FMPE

* All imports are fixed now

* Add dummy files to snpe/snre/snle folders to raise an explicit error

* formatting

* feedback from review
michaeldeistler added a commit that referenced this pull request Aug 28, 2024
* move all inference methods into `trainers` folder

* remove the "S" from all inference methods

* Rename FMPE

* All imports are fixed now

* Add dummy files to snpe/snre/snle folders to raise an explicit error

* formatting

* feedback from review
michaeldeistler added a commit that referenced this pull request Aug 28, 2024
* refactor: move all inference methods into `trainers` folder (#1238)

* move all inference methods into `trainers` folder

* remove the "S" from all inference methods

* Rename FMPE

* All imports are fixed now

* Add dummy files to snpe/snre/snle folders to raise an explicit error

* formatting

* feedback from review

* Rename SN(P)E -> N(P)E in tests

* Rename SN(P)E -> N(P)E in all tutorials

* Rename SN(P)E -> N(P)E in all documentation

* Remove `infer` method from docs

* Remove simulate_for_sbi from tutorial

* update implemented methods

* rename in tests

* fixup

* modify tutorial
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.

Refactor neural_nets model structure

2 participants