Please help me, I have a problem with DQNAgent.
See original GitHub issueTypeError 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:
- Created 3 years ago
- Comments:12
Already solved my error installing https://github.com/wau/keras-rl2 instead of https://github.com/keras-rl/keras-rl
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.