-
Notifications
You must be signed in to change notification settings - Fork 479
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
Strange import issue --> AttributeError: module 'captum' has no attribute 'attr' #680
Comments
Thank you for raising the issue, @adaruna3 ! We will look into it. |
Hi @adaruna3 , I think this is likely expected behavior, since importing a module doesn't automatically import all submodules. This would only occur if the main captum init imported the specific submodules, which is not currently the case, so you would need to either do |
Hi Vivek, totally understand. Ultimately it depends on the design choices of the developers. I am used to importing the main package I just mentioned it in case that behavior was not caught yet. But if having an import for each module in the package is intended design, that works too. Thanks!! |
Summary: This fixes issue #680 Strange import issue --> AttributeError: module 'captum' has no attribute 'attr' In most python packages, you can import the toplevel package, like numpy, scipy, torch, etc.. and then access the submodules simply by the dot-operator. Like you can use `import numpy` and after that you can use any submodules à la `numpy.random.uniform`. With this PR, you can just `import captum` and then for example use `captum.attr.DeepLift` or `captum.robust.Perturbation` instead of having to import both. It's just a small convenience, and I think there are more people that expect this kind of import to work but don't bother to create an issue out of this. I hope this PR is considered as helpful. Pull Request resolved: #912 Reviewed By: NarineK Differential Revision: D37053826 Pulled By: vivekmig fbshipit-source-id: 64fa2be7651ca30571d1eb85b45dd11410676c4b
🐛 AttributeError: module 'captum' has no attribute 'attr'
When importing captum with just
import captum
, the package is missing modules like attr. Runningdir(captum)
shows that the other modules, likeattr
are missing. However, if a statement likefrom captum.attr._utils.input_layer_wrapper import ModelInputWrapper
is included afterimport captum
, the captum package then has the missing modules. Again, verified by running adir(captum)
. Is this expected behavior?To Reproduce
Steps to reproduce the behavior:
Expected behavior
I assume all modules should be available after
import captum
. If this behavior is not expected, please close and disregard.Environment
I installed captum using the suggested conda method. See details below. After noticing this issue in an environment I was developing in with many other packages, I made a new, clean environment that only contained captum and any dependencies conda installed. Same issue.
conda
,pip
, source): condaconda install captum -c pytorch
The text was updated successfully, but these errors were encountered: