devsisters / DQN-tensorflow

Tensorflow implementation of Human-Level Control through Deep Reinforcement Learning
MIT License
2.46k stars 765 forks source link

unsupported operand type(s) for +: 'dict_values' and 'list #51

Closed tygrer closed 6 years ago

tygrer commented 6 years ago

When I use python3.6 to implement the program, the error shows :

Traceback (most recent call last): File "main.py", line 70, in tf.app.run() File "/home/tanggy/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "main.py", line 62, in main agent = Agent(config, env, sess) File "/home/tanggy/Downloads/DQN-tensorflow-master/dqn/agent.py", line 30, in init self.build_dqn() File "/home/tanggy/Downloads/DQN-tensorflow-master/dqn/agent.py", line 328, in build_dqn self._saver = tf.train.Saver(self.w.values() + [self.step_op], max_to_keep=30) TypeError: unsupported operand type(s) for +: 'dict_values' and 'list

tennenboke commented 6 years ago

Hi,I met the same problem.How did you fix it?Thank for your replay.

liziyan16 commented 5 years ago

@tennenboke @tygrer Hi, I met the same problem when using python 3.5 and don't know how to fix it. Looking forward to your replay, thanks!

douglasrizzo commented 5 years ago

Hi everyone. I am fairly sure that this is the source of the problem. In Python 2, dict.values() returns a list, but in Python 3 it returns a "view", which I'm not sure what it is. I just tested and it's possible to cast the return of dict.values() to a list. Maybe someone can test a fix like this one:

self._saver = tf.train.Saver(list(self.w.values()) + [self.step_op], max_to_keep=30)