tensorflow: WARNING:tensorflow:Entity at 0x000002343DCF24C8> could not be transformed and will be executed as-is.

What can be done to solve this warning?

Warning message

Below is the full warning:

WARNING:tensorflow:Entity <function <lambda> at 0x000002343DCF24C8> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause: module ‘gast’ has no attribute ‘Str’ WARNING: Entity <function <lambda> at 0x000002343DCF24C8> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause: module ‘gast’ has no attribute ‘Str’

Minimum working example

The code that generated the warning was discussed in #38471 and stored in this gist.

import tensorflow as tf

def compute_length(x): 
    return tf.strings.length(x)

def check_substring(x, substring):
    return tf.strings.regex_full_match(x,substring)


def compute_palindrome(x):
    extra_split = tf.strings.bytes_split(x)
    reverse = tf.reverse(extra_split,[0])
    reversedStr = tf.strings.reduce_join([reverse])
    return reversedStr
    
ds = tf.data.Dataset.from_tensor_slices(["Ottawa", "Stockholm", "Rabat"])

ds = ds.map(
    lambda city: (city, 
                  compute_length(city), 
                  check_substring(city, ".*lm.*"),
                  compute_palindrome(city),
                  ),
        )

num_elems = len(ds.element_spec)
for elem in ds:
   print(''.join([f"{elem[i]}" for i in range(num_elems)]))

Environment

  • python 3.7.4
  • tensorflow-gpu 2.0.0
  • tensorflow-datasets 1.3.0
  • gast 0.2.2

Running on Windows 10 under conda 4.8.3.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Hi @ssnirgudkar, it appears that the error message indicates an environment related incompatibility. The root cause it indicated by this piece in the message: “Original error: could not get source code”. This section in the docs has a few details why.

Given that the lambda function is simple, you could try to wrap it into a tf.autograph.experimental.do_not_convert, but it is likely to see that error for all the other functions that might be involved. That type of error will also happen if you upgrade to a newer version of TF, so I think it’s worth looking at the environment instead.

Are you getting this error when trying to run the code in an interactive Python or IPython shell? I know those to be incompatible. Running the code as a Python file, or using something like Jupyter should work though.

@laghaout Can you please test with tf-nightly or TF2.2.0rc3 and let us know whether the error persists with latest versions also. Thanks!