You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imports from sbi.neural_nets.* result in a circular import due to the interactions between sbi.utils.__init__.py and sbi.utils.get_nn_models with sbi.neural_nets. E.g., from sbi.neural_nets.flow import build_nsf gives:
>>> from sbi.neural_nets.flow import build_nsf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/matthew/.pyenv/versions/sbi/lib/python3.8/site-packages/sbi/neural_nets/flow.py", line 14, in <module>
from sbi.utils.sbiutils import (
File "/home/matthew/.pyenv/versions/sbi/lib/python3.8/site-packages/sbi/utils/__init__.py", line 4, in <module>
from sbi.utils.get_nn_models import classifier_nn, likelihood_nn, posterior_nn
File "/home/matthew/.pyenv/versions/sbi/lib/python3.8/site-packages/sbi/utils/get_nn_models.py", line 14, in <module>
from sbi.neural_nets.flow import build_made, build_maf, build_nsf
ImportError: cannot import name 'build_made' from partially initialized module 'sbi.neural_nets.flow' (most likely due to a circular import) (/home/matthew/.pyenv/versions/sbi/lib/python3.8/site-packages/sbi/neural_nets/flow.py)
This is because the sbi.neural_nets.* import sbi.utils, in which sbi.utils.get_nn_models then imports sbi.neural_nets.
One can instead use, e.g., from sbi.utils.get_nn_models import build_nsf or import sbi.utils; from sbi.neural_nets.flow import build_nsf, or the documented interface sbi.utils.get_nn_models.posterior_nn. But the first two options are less intuitive and the last obfuscates the parameters of the chosen model.
The text was updated successfully, but these errors were encountered:
Imports from
sbi.neural_nets.*
result in a circular import due to the interactions betweensbi.utils.__init__.py
andsbi.utils.get_nn_models
withsbi.neural_nets
. E.g.,from sbi.neural_nets.flow import build_nsf
gives:This is because the
sbi.neural_nets.*
importsbi.utils
, in whichsbi.utils.get_nn_models
then importssbi.neural_nets
.One can instead use, e.g.,
from sbi.utils.get_nn_models import build_nsf
orimport sbi.utils; from sbi.neural_nets.flow import build_nsf
, or the documented interfacesbi.utils.get_nn_models.posterior_nn
. But the first two options are less intuitive and the last obfuscates the parameters of the chosen model.The text was updated successfully, but these errors were encountered: