keras-rl / keras-rl

Deep Reinforcement Learning for Keras.

Home Page:http://keras-rl.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please help me, I have a problem with DQNAgent.

hemsatrakol opened this issue · comments

TypeError Traceback (most recent call last)
in ()
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.

I'm having the same issue, what keras and tensorflow versions do you have installed?

i am getting the same error i have tensorflow==2.4.0
OS:Windows

try to see this issue #348

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
Yes, another good solution

Thank you jaortegab & TheTrash. The issue can be resolved by installing keral-rl2
👍

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
Yes, another good solution

why I can't find anything?

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
Yes, another good solution

why I can't find anything?

same. Please help us.

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.

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
Yes, another good solution

why I can't find anything?

same. Please help us.

keras-rl/keras-rl is specifically designed for Tensorflow1 + Keras,
If you are using TF2, best is to use keras-rl2 as @SimonHashtag, @jaortegab and @TheTrash suggested

Try installing keras-rl2 version 1.0.4.

pip install keras-rl2==1.0.4

Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
Yes, another good solution

why I can't find anything?

same. Please help us.