-
Notifications
You must be signed in to change notification settings - Fork 196
Logit transform #1485
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
Merged
Merged
Logit transform #1485
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
e503c88
logit transform changes
f488f86
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 3737ee6
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 8be9079
add new ZScoreTypes
23bd180
add new ZScoreTypes
162b976
resolving bug z_scoring last year
c5772d2
resolving bug z_scoring last year
b279eb0
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 993efb7
revert z_score parser
443b8ef
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 862f3d2
adjusted logit structure in build_zuko_flow
bccd82b
resolve pyright error
3e3a8d5
Merge branch 'main' into logit_transform
anastasiakrouglova 145ef4e
revert flow as a test
5a26157
add x_dist variable
0dd3baa
add logit to sbiutils_test.py
000c123
add logit if statement
b3bc54b
add logit if statement
fa80559
add logit if statement
1de1a98
add logit if statement
e2007af
remove logit if statement
1603756
resolve pyright issues
1ffd0e9
cover logit in tests
73af5ac
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 9cc887b
cover tests for logit in flow.py
9573905
cover tests for CNF
adff499
adding faq for logit transformation
8176707
adding faq for logit transformation
12c4c85
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova 69502d7
stash changes
d617030
feedback guy adjustments
9037534
add documentation if statements
db361a0
update sbiutils
d660631
resolve comment 1 and 2 of Jan
9332583
ruff linted push
7dcf919
cleanup density_estimator_test.py
bbca1ed
cleanup density_estimator_test.py and ruff check
7142ccb
Merge branch 'sbi-dev:main' into logit_transform
anastasiakrouglova b09ebb7
adjusted docstrings
8c029f4
add tests convergence unconstrained space
d63af48
adjust faq
9fb371a
add test snle
be06d58
adjust linear gaussian and estimate c2st
c732ded
adjust documentation
021d67f
Update sbi/neural_nets/net_builders/flow.py
anastasiakrouglova d375df9
Update sbi/utils/sbiutils.py
anastasiakrouglova bd0c055
Update sbi/utils/sbiutils.py
anastasiakrouglova 3908896
add literal import to sbi utils
33129d8
adjust literals and add get_transform_to_unconstrained
580fd50
adjust literals and format
dfd9948
add new line for ruff
d6dca31
stying ruff
b8cd4da
stying ruff
e528737
fix flow builder z-score defaults.
janfb 0665400
refactor zuko flow build functions
janfb 4d4bfb8
re-use y-embedding helper function.
janfb 8946a09
fix typing
janfb 89f990c
Merge branch 'main' into logit_transform
janfb 340ba70
small fixes.
janfb c4aa2d1
fix unconstrained nle test
janfb 1ee797d
refactor z-score-parser test
janfb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Using the logit transformation | ||
If you've ruled out simulator issues, you can try | ||
training your density or ratio estimator in an unbounded space | ||
using a logit transformation: | ||
|
||
- **For NPE**: The transformation maps bounded parameters θ | ||
to unbounded space before training, then applies the inverse (sigmoid) | ||
after training to ensure posterior samples stay within prior bounds. | ||
|
||
- **For NLE/NRE**: The transformation would need to map bounded | ||
data x to unbounded space, which requires estimating data bounds | ||
from simulations (more complex). | ||
|
||
To enable this for NPE: | ||
|
||
```python | ||
density_estimator_build_fun = posterior_nn( | ||
model="zuko_nsf", | ||
hidden_features=60, | ||
num_transforms=3, | ||
z_score_theta="transform_to_unconstrained" # Transforms parameters to unconstrained space | ||
x_dist=prior # For NPE, this specifies bounds for parameters (internally called 'x') | ||
) | ||
inference = NPE(prior, density_estimator=density_estimator_build_fun) | ||
``` | ||
|
||
This ensures that your density estimator operates in a | ||
transformed space where it respects prior bounds, | ||
improving the efficiency of rejection sampling. | ||
|
||
Note: The `x_dist=prior` might seem confusing - internally, | ||
sbi uses generic `x,y` notation where for NPE, `x` represents | ||
parameters (θ) and `y` represents data. | ||
This is why we pass the prior as `x_dist`. | ||
|
||
Important: | ||
|
||
- This transformation is currently only supported for zuko density estimators. | ||
- For **NLE/NRE**, setting up this transformation is more | ||
complex as it requires estimating bounds for the simulated data | ||
rather than using prior bounds. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.