question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please help me, I have a problem with DQNAgent.

See original GitHub issue

TypeError Traceback (most recent call last) <ipython-input-53-91d9f9d50d46> in <module>() 1 policy = EpsGreedyQPolicy() 2 memory = SequentialMemory(limit=50000, window_length=1) ----> 3 dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10,target_model_update=1e-2, policy=policy) 4 dqn.compile(Adam(lr=1e-3), metrics=[‘mae’]) 5

1 frames /usr/local/lib/python3.6/dist-packages/rl/agents/dqn.py in init(self, model, policy, test_policy, enable_double_dqn, enable_dueling_network, dueling_type, *args, **kwargs) 106 107 # Validate (important) input. –> 108 if hasattr(model.output, ‘len’) and len(model.output) > 1: 109 raise ValueError(‘Model “{}” has more than one output. DQN expects a model that has a single output.’.format(model)) 110 if model.output._keras_shape != (None, self.nb_actions):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/keras_tensor.py in len(self) 238 239 def len(self): –> 240 raise TypeError('Keras symbolic inputs/outputs do not ’ 241 'implement __len__. You may be ’ 242 'trying to pass Keras symbolic inputs/outputs ’

TypeError: Keras symbolic inputs/outputs do not implement __len__. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

15reactions
jaortegabcommented, Jan 6, 2021

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl

3reactions
SimonHashtagcommented, Oct 11, 2021

You can install the keras-rl2 package by typing the following into your terminal: pip install keras-rl2

The repo for the keras-rl2 package can be found here: https://github.com/taylormcnally/keras-rl2

With this installed the dqn-agent should work fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reinforced learning agent build DQNAgent causes unknown ...
I wanted to get into reinforced learning a bit, so I started with the fairly simple example "Cartpole" by following a hands-on tutorial....
Read more >
[P] DQN agent not learning/getting better, custom environment ...
I have made a custom environment to train an RL agent for crypto trading. ... 2 controllable variables and 9 uncontrollable variables, HELP!...
Read more >
Training & Testing Deep reinforcement learning (DQN) Agent
Welcome to part 2 of the deep Q-learning with Deep Q Networks (DQNs) tutorials. In the previous tutorial, we were working on our...
Read more >
keras agents fails in DQNAgent using PQC during clonation ...
I have some issues using keras-rl2 with tensorflow_quantum and VQC (using ... After the creation of the model and DqnAgent, in dqn.compile:
Read more >
Reinforcement Learning with TensorFlow Agents — Tutorial
Let me know in responses what you think about TF-Agents, and also if you have any question or you found any in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found