Skip to content
This repository was archived by the owner on Dec 2, 2023. It is now read-only.

Error in tangent tutorial notebook: "AttributeError: module 'gast' has no attribute 'Num'" #105

Open
dariush-bahrami opened this issue Jan 20, 2021 · 6 comments

Comments

@dariush-bahrami
Copy link

Hi i opened your tutorial notebook and run the cells in notebook. after installing tangent at cell with following code:

import tangent
df = tangent.grad(f)

the following error arises:

AttributeError Traceback (most recent call last)
in ()
----> 1 import tangent
2 df = tangent.grad(f)

3 frames
/usr/local/lib/python3.6/dist-packages/tangent/grammar.py in ()
16 import gast
17
---> 18 LITERALS = (gast.Num, gast.Str, gast.Bytes, gast.Ellipsis, gast.NameConstant)
19
20 CONTROL_FLOW = (gast.For, gast.AsyncFor, gast.While, gast.If, gast.Try)

AttributeError: module 'gast' has no attribute 'Num'

@mdanatg
Copy link

mdanatg commented Jan 20, 2021

This is due to incompatible dependencies. We haven't had the chance to upgrade the code. Could you try installing an older version of gast:

pip install gast==0.2.4

@Pyrofoux
Copy link

Pyrofoux commented Feb 15, 2022

This yield the issue:

ERROR: Could not find a version that satisfies the requirement gast==0.2.4 (from versions: 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.2.0, 0.2.1, 0.2.1.post0, 0.2.1.post1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3)
ERROR: No matching distribution found for gast==0.2.4

Looks like there's no gast 0.2.4.

Using 0.3.0 yields

[/usr/local/lib/python3.7/dist-packages/tangent/grammar.py](https://localhost:8080/#) in <module>()
     16 import gast
     17 
---> 18 LITERALS = (gast.Num, gast.Str, gast.Bytes, gast.Ellipsis, gast.NameConstant)
     19 
     20 CONTROL_FLOW = (gast.For, gast.AsyncFor, gast.While, gast.If, gast.Try)

AttributeError: module 'gast' has no attribute 'Num'

while using 0.2.2 yields

[/usr/local/lib/python3.7/dist-packages/tangent/tf_extensions.py](https://localhost:8080/#) in <module>()
     58 
     59 non_differentiable.register_non_differentiable_functions(
---> 60     tf.shape, tf.to_float, tf.equal, tf.constant,
     61     tf.zeros, tf.ones, tf.zeros_like, tf.ones_like,
     62     size, shape_as_list, dtype)

AttributeError: module 'tensorflow' has no attribute 'to_float'

All these examples are from the Colab notebook. It's such a shame Tangent isn't functional anymore, it would have been pretty useful.

@mdanatg
Copy link

mdanatg commented Feb 15, 2022

Odd that that version is gone. Does 0.2.2 work instead?

@Pyrofoux
Copy link

No, both 0.3.0 and 0.2.2 do not work. My previous comment contains errors for both versions!

@mdanatg
Copy link

mdanatg commented Feb 25, 2022

That means that the code would need to be upgraded to the newest version. Not terribly difficult, it's mostly mechanical, if anyone has the bandwitdth to do it.

@smbarr
Copy link

smbarr commented Jul 27, 2022

I took a stab at upgrading to gast 0.3.0 in smbarr/tangent-upgrade-gast

Most of the tests seem to be passing now, but I'm having a lot of trouble getting some of the tensorflow derivatives to work.

I would really like to get all the tests passing, so if anyone has an idea of how to do that I'm happy to help further. This is a really interesting and unique project which I'd hate to see die.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants