'WARNING:tensorflow:Entity <function get_tensorlists at ...> could not be transformed and will be executed as-is

In Spyder 4.0.1, when I run the following code

import tensorflow as tf

@tf.function
def get_tensorlists(m,n,max=7):
  list1 = tf.random.uniform([m,n],0,max,seed=0)
  list2 = tf.random.uniform([m,n],0,max,seed=0)
  return list1,list2

@tf.function
def get_dataset(X,Y,epochs):
  set = tf.data.Dataset.from_tensor_slices((X,Y))
  # adjust it the way we need
  set = set.shuffle(100).repeat(epochs).batch(1)
  return set

temp = get_tensorlists(10,1)
X = temp[0]
Y = temp[1]
dataset = get_dataset(X,Y,1)

print(dataset)
i = 0
for (x,y) in dataset:
  i+=1
  print(i)
  print(x,y)

I get this error print:

WARNING:tensorflow:Entity <function get_tensorlists at 0x000001DA9852C798> could not be transformed and will be executed as-is.
Please report this to the AutgoGraph team.

The only suggestion I found is to install pip install gast==0.2.2 and restart Spyder. But that didn't change anything for me.

So, how can I get rid of this error?



Solution 1:[1]

This worked for me:

  • Uninstall TensorFlow by manually deleting every single file that contains "tensor" in it (and belongs to TensorFlow)
  • Uninstall gast using conda uninstall gast
  • Reinstall TensorFlow using conda install tensorflow
  • Reinstall TensorFlow using conda install gast

The error doesn't appear anymore now.


Besides that, the output I get is still senseless and not what should be printed. I've finally also solved the output problem, I hade to downgrade TF: pip install tensorflow==2.0.0

EDIT: I wouldn't recommend anyone to delete the files manually, that usually causes a whole lot of trouble - although it worked for me here.

Solution 2:[2]

The Newer version of gast causes the warning, to resolve:

conda install 'gast==0.2.2'

or if you are using pip

pip install 'gast==0.2.2'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Bikky Kumar