addons: Entity could not be transformed

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.0.0-dev20190317 (gpu nightly)
  • TensorFlow Addons installed from (source, PyPi): source
  • TensorFlow Addons version: master
  • Python version and type (eg. Anaconda Python, Stock Python as in Mac, or homebrew installed Python etc): anaconda (conda-forge) python 3.7.1
  • Bazel version (if compiling from source): 0.20.0
  • GCC/Compiler version (if compiling from source): 7.3.0
  • Is GPU used? (yes/no): yes
  • GPU model (if used): RTX 2070

I’m seeing the following warning appear when trying to use the transform op. The simplest way to reproduce is to simply run the tests via python:

python ~/src/addons/tensorflow_addons/image/transform_test.py
[...]
W0317 18:03:00.753756 139906711668544 tf_logging.py:161] Entity <function image_projective_transform_v2 at 0x7f3e73a05a60> could not be transformed and will be staged without change. Error details can be found in the logs when running with the env variable AUTOGRAPH_VERBOSITY >= 1. Please report this to the AutoGraph team. Cause: Unexpected error transforming <function image_projective_transform_v2 at 0x7f3e73a05a60>. If you believe this is due to a bug, please set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output when filing the bug report. Caused by: Unable to locate the source code of <function image_projective_transform_v2 at 0x7f3e73a05a60>. Note that functions defined in certain environments, like the interactive Python shell do not expose their source code. If that is the case, you should to define them in a .py source file. If you are certain the code is graph-compatible, wrap the call using @tf.autograph.do_not_convert. Original error: could not get source code

export AUTOGRAPH_VERBOSITY=10
python ~/src/addons/tensorflow_addons/image/transform_test.py
[...]
I0317 18:11:38.742995 140338201401152 ag_logging.py:132] Error transforming <function image_projective_transform_v2 at 0x7fa2ea6b2a60>
Traceback (most recent call last):
  File "~/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/parser.py", line 51, in parse_entity
    source = tf_inspect.getsource_no_unwrap(entity)
  File "~/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/util/tf_inspect.py", line 408, in getsource_no_unwrap
    lines, lnum = _inspect.findsource(obj)
  File "~/miniconda3/envs/tf2/lib/python3.7/inspect.py", line 786, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

Is this expected? I expect this is likely an artifact of a broken source build on my end, but I imagine others may experience similar issues until the CI/CD system is building nightly versions for all platforms and python versions.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I just checked the test with the nightly and the warnings should go away now - can you confirm?

Thanks, the docker container worked, and I found the culprit as well. It seems that our own op loader generates some dynamic code using exec, which discards source code information. I’ll have a fix shortly to handle those properly.

The warning is otherwise absolutely benign, but sorry for the annoyance it created!

feature_extractor_url ="https://tfhub.dev/google/tf2-preview/mobilenet_v2/classification/2" #@param {type:"string"}

feature_extrator_layer = hub.KerasLayer(feature_extractor_url, input_shape=IMAGE_SHAPE+(3,))

model = tf.keras.Sequential([
  feature_extractor_layer,
  layers.Dense(image_data_train.num_classes, activation='softmax')
])

model.summary()

WARNING:tensorflow:Entity <bound method KerasLayer.call of <tensorflow_hub.keras_layer.KerasLayer object at 0x13180d390>> 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 ‘Num’ WARNING:tensorflow:Entity <bound method KerasLayer.call of <tensorflow_hub.keras_layer.KerasLayer object at 0x13180d390>> 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 ‘Num’ WARNING: Entity <bound method KerasLayer.call of <tensorflow_hub.keras_layer.KerasLayer object at 0x13180d390>> 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 ‘Num’

Will do! Feel free to add me to the Assignees list but we linked an internal bug to the issue.

Last note: I’ve seen the same warning in very basic non-test calculations, but I figured executing the test script manually is a pretty good way to reproduce the issue initially.

edit Here’s a minimal example that triggers the same warning:

import numpy as np
import tensorflow as tf
import tensorflow_addons as tfa
from tensorflow_addons.image.transform_ops import angles_to_projective_transforms

minval = 10 * np.pi / 180.
maxval = -1.0 * minval

n_images = 10
x = tf.eye(28, 28, [n_images])
random_angles = tf.random.uniform(shape=[1], minval=minval, maxval=maxval)
transforms = angles_to_projective_transforms(random_angles, 28, 28)
transforms = transforms[0:1]
rotated_images = tfa.image.transform(x, transforms)