DQN-tensorflow icon indicating copy to clipboard operation
DQN-tensorflow copied to clipboard

Python 3.x compatibility issues

Open b0b3rt opened this issue 8 years ago • 1 comments

Code requires: from functools import reduce #py2.7 reduce > py3.x functools.reduce s/xrange/range #py2.7 xrange > py3.x range

Issue after those are fixed:

Traceback (most recent call last):
  File "main.py", line 70, in <module>
    tf.app.run()
  File "/usr/local/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 62, in main
    agent = Agent(config, env, sess)
  File "/Users/emmanuel.mwangi/open_source/laml/DQN-tensorflow/dqn/agent.py", line 31, in __init__
    self.build_dqn()
  File "/Users/emmanuel.mwangi/open_source/laml/DQN-tensorflow/dqn/agent.py", line 329, 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'

b0b3rt avatar Sep 08 '17 04:09 b0b3rt

Refer to this: https://stackoverflow.com/questions/43663206/typeerror-unsupported-operand-types-for-dict-values-and-int

Simply convert self.w.values() to list before the sum will do the trick. (i.e. list(self.w.values()))

GeneDer avatar Sep 20 '17 02:09 GeneDer