germain-hug/Deep-RL-Keras

A3C: Issue with keras.function in optimizer

Opened this issue · 4 comments

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

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

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?

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

@yosoul93 I think this is helpful