tangent icon indicating copy to clipboard operation
tangent copied to clipboard

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

Open dariush-bahrami opened this issue 4 years ago • 6 comments

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'

dariush-bahrami avatar Jan 20 '21 11:01 dariush-bahrami

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

mdanatg avatar Jan 20 '21 13:01 mdanatg

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.

Pyrofoux avatar Feb 15 '22 22:02 Pyrofoux

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

mdanatg avatar Feb 15 '22 22:02 mdanatg

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

Pyrofoux avatar Feb 25 '22 10:02 Pyrofoux

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.

mdanatg avatar Feb 25 '22 15:02 mdanatg

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.

smbarr avatar Jul 27 '22 02:07 smbarr