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
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 2.0.0-beta1
- Python version: 3.6.8
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A
You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)" 2. TF 2.0: python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
Describe the current behavior
I know how to create tf.keras.Model with functional api for sure. I created a tf.keras.Model with no input tensors with functional api. When I call it, tensorflow complains that
AttributeError: Tensor.op is meaningless when eager execution is enabled.
Describe the expected behavior
The tf.keras.Model should return expected value rather than raising a error.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
#!/usr/bin/python3
import tensorflow as tf;
def model():
a = tf.keras.layers.Lambda(lambda x: tf.ones(x))((2,3,4));
return tf.keras.Model(inputs = [], outputs = a);
b = model()();
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
Traceback (most recent call last):
File "test.py", line 9, in
b = model()();
File "test.py", line 7, in model
return tf.keras.Model(inputs = [], outputs = a);
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 133, in init
super(Model, self).init(*args, **kwargs)
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 161, in init
self._init_graph_network(*args, **kwargs)
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py", line 458, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 267, in _init_graph_network
base_layer_utils.create_keras_history(self._nested_outputs)
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 199, in create_keras_history
_, created_layers = _create_keras_history_helper(tensors, set(), [])
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 225, in _create_keras_history_helper
op = tensor.op # The Op that created this Tensor.
File "/home/xieyi/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 987, in op
"Tensor.op is meaningless when eager execution is enabled.")
AttributeError: Tensor.op is meaningless when eager execution is enabled.
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
You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0:
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"2. TF 2.0:python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"Describe the current behavior
I know how to create tf.keras.Model with functional api for sure. I created a tf.keras.Model with no input tensors with functional api. When I call it, tensorflow complains that
Describe the expected behavior
The tf.keras.Model should return expected value rather than raising a error.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.