tensorflow: tensorflow.python.eager.core._FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
-
Custom code
-
Ubuntu 18
-
TensorFlow installed from source:
-
TensorFlow version :2.0
-
Python version: 3.6
-
CUDA/cuDNN version:10.0/
-
GPU model and memory: 1080Ti/11Go
Contrary to the docs, tf.print do not handle printing tensors in a session run (for example when building a keras model with the model API) https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/print
Describe the expected behavior I expect the example shown in the docs to run smoothly
Code to reproduce the issue
import os
import tensorflow as tf
from tensorflow.keras.layers import BatchNormalization
import numpy as np
input = np.random.uniform(size=(6, 40, 40, 1)).astype(np.float32)
ds = tf.data.Dataset.from_tensor_slices(input).batch(2)
iterator = iter(ds)
inp = tf.keras.Input((None, None, 1))
print_op = tf.print(inp)
with tf.control_dependencies([print_op]):
out = tf.keras.layers.Conv2D(5, 3)(inp)
model = tf.keras.Model(inputs=inp, outputs=out)
model(next(iterator))
Which raises:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_string_ops.py", line 807, in string_format
summarize)
tensorflow.python.eager.core._FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "log_test.py", line 13, in <module>
print_op = tf.print(inp)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/logging_ops.py", line 339, in print_v2
name=format_name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/string_ops.py", line 192, in string_format
name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_string_ops.py", line 813, in string_format
summarize=summarize, name=name, ctx=_ctx)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_string_ops.py", line 867, in string_format_eager_fallback
_attr_T, inputs = _execute.convert_to_mixed_eager_tensors(inputs, _ctx)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 210, in convert_to_mixed_eager_tensors
types = [t._datatype_enum() for t in v] # pylint: disable=protected-access
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 210, in <listcomp>
types = [t._datatype_enum() for t in v] # pylint: disable=protected-access
AttributeError: 'Tensor' object has no attribute '_datatype_enum'
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 21 (2 by maintainers)
I am still getting this error and I am not using control_dependencies
I had this issue with Tensorflow 2.0.0. Downgrading to 1.13.2 resolved the issue, which for me was an acceptable solution.