germain-hug / Deep-RL-Keras

Keras Implementation of popular Deep RL Algorithms (A3C, DDQN, DDPG, Dueling DDQN)
528 stars 149 forks source link

A3C: Issue with keras.function in optimizer #22

Open AlconDivino opened 4 years ago

AlconDivino commented 4 years ago

When the optimize function of the actor is called, i get the following error:

Traceback (most recent call last): File "/home/alcon/Desktop/DRL-Python/A3CMain.py", line 41, in <module> A3C(action_dim, env_dim, args.consecutive_frames) File "/home/alcon/Desktop/DRL-Python/A3C/a3cNetwork.py", line 33, in __init__ self.a_opt = self.actor.optimizer() File "/home/alcon/Desktop/DRL-Python/A3C/actor.py", line 39, in optimizer return K.function(inputs=[self.model.input, self.action_pl, self.advantages_pl], outputs=[], updates=updates) File "/home/alcon/Desktop/DRL-Python/venv/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 3479, in function return GraphExecutionFunction(inputs, outputs, updates=updates, **kwargs) File "/home/alcon/Desktop/DRL-Python/venv/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 3142, in __init__ with ops.control_dependencies([self.outputs[0]]): IndexError: list index out of range

I found code on the internet using it but for some reason it doesn't work for me

I tried it with tensorflow 1.15 - 2.0.0 and tried importing tensorflow.keras.backend tensorflow.compat.v1.keras.backend tensorflow.compat.v2.keras.backend but none worked

thangdn3 commented 4 years ago

K.function() with output = [] yeild error given the newer version of Keras. Down-grade it to 2.1.6 like suggested in the README.

shtse8 commented 4 years ago

K.function() with output = [] yeild error given the newer version of Keras. Down-grade it to 2.1.6 like suggested in the README.

I have the same issue. Besides downgrade, how can we fix?

yosoul93 commented 3 years ago

To fix it without downgrading, outputs=[K.constant([0,1])]

choasLC commented 2 years ago

@yosoul93 I think this is helpful