Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

AttributeError: Tensor.op is meaningless when eager execution is enabled #15

Closed
3 tasks done
cboettig opened this issue Apr 6, 2020 · 2 comments
Closed
3 tasks done

Comments

@cboettig
Copy link

cboettig commented Apr 6, 2020

  • Check that you are up-to-date with the master branch of Keras-RL. You can update with:
    pip install git+git://github.com/wau/keras-rl2.git --upgrade --no-deps

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short). If you report an error, please include the error message and the backtrace.

I am running the example scripts after installing precisely as documented above.

python examples/dqn_cartpole.py

Produces the error and trace:

raining for 50000 steps ...
2020-04-06 16:34:29.589490: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1483] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set.  If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU.  To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
/opt/venv/keras-rl2/lib/python3.6/site-packages/rl/memory.py:40: UserWarning: Not enough entries to sample without replacement. Consider increasing your warm-up phase to avoid oversampling!
  warnings.warn('Not enough entries to sample without replacement. Consider increasing your warm-up phase to avoid oversampling!')
Traceback (most recent call last):
  File "examples/dqn_cartpole.py", line 46, in <module>
    dqn.fit(env, nb_steps=50000, visualize=False, verbose=2)
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/rl/core.py", line 194, in fit
    metrics = self.backward(reward, terminal=done)
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/rl/agents/dqn.py", line 322, in backward
    metrics = self.trainable_model.train_on_batch(ins + [targets, masks], [dummy_targets, targets])
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 917, in train_on_batch
    self._make_train_function()
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1986, in _make_train_function
    **self._function_kwargs)
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 3544, in function
    return EagerExecutionFunction(inputs, outputs, updates=updates, name=name)
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 3438, in __init__
    add_sources=True, handle_captures=True, base_graph=source_graph)
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/eager/lift_to_graph.py", line 325, in lift_to_graph
    add_sources=add_sources))
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/eager/lift_to_graph.py", line 114, in _map_subgraph
    ops_to_visit = [_as_operation(init_tensor)]
  File "/opt/venv/keras-rl2/lib/python3.6/site-packages/tensorflow/python/eager/lift_to_graph.py", line 37, in _as_operation
    return op_or_tensor.op
  File "/opt/venv/keras-rl2/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.

(I'll note that editing the example to increase the warmup resolves the warning message, but I still see this same AttributeError message. I get the same error and trace when attempting the other examples as well.)

p.s. thanks for providing and maintaining this excellent resource!

@yanivg10
Copy link

I had the same issue. Add the following lines to the beginning of the code (where the import/from declarations are) and this issue will be solved:

from tensorflow.python.framework.ops import disable_eager_execution
disable_eager_execution()

@inarikami
Copy link
Owner

Resolved with #16

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants