-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
module 'sonnet' has no attribute 'AbstractModule' #128
Comments
@poweryin where is this Also, could you paste the output of running the following in your interpreter:
|
thanks,it is from kenetics-I3D repository.I figure it out .it is due to tensorflow's version is too low.thanks |
when i try to install the graph-nets , i meet the same problem....... |
@szq261299 would you mind printing the output of this in your Python interpreter: import sonnet as snt
print(dir(snt))
print(snt.__version__) |
@tomhennigan import sonnet as snt
print(dir(snt))
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
print(snt.__version__)
AttributeError Traceback (most recent call last)
<ipython-input-10-980fa547e124> in <module>
1 import sonnet as snt
2 print(dir(snt))
----> 3 print(snt.__version__)
AttributeError: module 'sonnet' has no attribute '__version__' In order to find the version number of sonnet, I type the following on the command line. pip list
...
dm-sonnet 1.33
... so what should I do ? |
I can't reproduce this in a clean colab. Perhaps you have a file in your current directory called |
print(snt.__file__)
AttributeError Traceback (most recent call last)
<ipython-input-5-86bcd137c072> in <module>
----> 1 print(snt.__file__)
AttributeError: module 'sonnet' has no attribute '__file__' |
@szq261299 what about |
When I uninstalled and reinstalled , it works now . But I can't reproduce this problem. It is so strange.... |
Thanks a lot~ |
Uninstalling + reinstalling seems to be a solution that worked for me = =. |
Uninstalling and reinstalling is not working for me. (tf-gpu)
Then
My tf and Sonnet version :
TensorFlow version 2.0.0 <module 'sonnet' from 'F:\Python\Python 3.6.8\lib\site-packages\sonnet\init.py'> |
Hey @ArnaudC, if the code you're using wants I'll see if we can give a better error message in this case, but for now you'll want to use the 1.X series of both TensorFlow and Sonnet. Also (to save you some time) the current stable version of $ pip install "tensorflow-gpu<2" "dm-sonnet<2" "tensorflow-probability==0.7.0" If you're developing new code then I would suggest using TensorFlow 2 and Sonnet 2 but if you have existing code that you don't want to rewrite then downgrading to TF1/Sonnet 1 should do the trick. |
Hey @tomhennigan, I need to upgrade to sonnet2/tf2, can you confirm is there any way to upgrade the code written in sonnet1 to sonnet2? For instance, the |
Hi @lucky096 there is no automated way to convert Sonnet 1 -> Sonnet 2 and the library is not backwards compatible. The main change between the Sonnet 1 and 2 is how variables and submodules are created and used. Sonnet 2 doesn't have any magical reuse of modules or variables, instead users are expected to use normal Python code to manage this (e.g. save parameters as We provide # TensorFlow 2 / Sonnet 2
class AddNModule(snt.Module):
@snt.once
def _initialize(self, x):
# Make sure to initialize variables and submodules once and only once.
self.n = tf.Variable(tf.ones(x.shape))
self.s = SomeSubModule()
def __call__(self, x):
self._initialize(x)
return self.s(self.n + x)
# TensorFlow 1 / Sonnet 1
class AddNModule(snt.AbstractModule):
def __call__(self, x):
n = tf.get_variable("n", x.shape, initializer=tf.ones)
return SomeSubModule()(n + x) I have ported a lot of code between Sonnet 1 -> Sonnet 2 and for most modules moving initialization into a method annotated with |
Hey, Based on the discussion above, I see that AbstractModule is not used in sonnet2.0. Do I have to go back to sonnet1.0 or is there a kinetics-i3d based on sonnet2.0? |
@tfqbasha as mentioned above, models written in Sonnet v1 will not work unmodified with V2. I would suggest asking the authors of Kinetics directly whether they are planning on making a Sonnet v2 version available. |
@tfqbasha you can follow this issue google-deepmind/kinetics-i3d#85 to see if the developers will respond to the update request. |
2022-05-20 11:39:34.302485: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll |
Hi,I've installed sonnet by using pip install dm-sonnet
However when I run "python evaluate_sample.py"
I got AttributeError: module 'sonnet' has no attribute 'AbstractModule'
Thanks!
The text was updated successfully, but these errors were encountered: