devsisters / DQN-tensorflow

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

KeyError: '__flags' #50

Open jdmartin86 opened 6 years ago

jdmartin86 commented 6 years ago

After following the install instructions and running python main.py --env_name=Breakout-v0 --is_train=True I receive the following error

Traceback (most recent call last):
  File "main.py", line 70, in <module>
    tf.app.run()
  File "/home/jdmartin86/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "main.py", line 49, in main
    config = get_config(FLAGS) or FLAGS
  File "/home/jdmartin86/sandbox/test-qlearn/DQN-tensorflow/config.py", line 58, in get_config
    for k, v in FLAGS.__dict__['__flags'].items():
KeyError: '__flags'
redmouth commented 6 years ago

you can try modifying function get_config(FLAGS) into following:

def get_config(FLAGS):
  if FLAGS.model == 'm1':
    config = M1
  # elif FLAGS.model == 'm2':
  #   config = M2

  # for k, v in FLAGS.__dict__['__flags'].items():
  for k, v in FLAGS.__flags.items():
    if k == 'use_gpu':
      if v.value == False:
        config.cnn_format = 'NHWC'
      else:
        config.cnn_format = 'NCHW'

    if hasattr(config, k):
      setattr(config, k, v.value)

  return config
jdmartin86 commented 6 years ago

Thanks for the response. After making your proposed update, I receive the following memory error.

Traceback (most recent call last):
  File "main.py", line 70, in <module>
    tf.app.run()
  File "/home/jdmartin86/anaconda2/lib/python2.7/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/jdmartin86/sandbox/test-qlearn/DQN-tensorflow/dqn/agent.py", line 23, in __init__
    self.memory = ReplayMemory(self.config, self.model_dir)
  File "/home/jdmartin86/sandbox/test-qlearn/DQN-tensorflow/dqn/replay_memory.py", line 18, in __init__
    self.screens = np.empty((self.memory_size, config.screen_height, config.screen_width), dtype = np.float16)
MemoryError

Is this unrelated?

shelleyo9 commented 6 years ago

I met the same MemoryError problem as you, then I modify the memory_size in config.py to a smaller value and then it works. Hope this helps you.

dwsmith1983 commented 6 years ago
  for k in FLAGS.__dict__['__wrapped']:
        if k == 'use_gpu':
            if not FLAGS.__getattr__(k):
                config.cnn_format = 'NHWC'
            else:
                config.cnn_format = 'NCHW'

    if hasattr(config, k):
        setattr(config, k, FLAGS.__getattr__(k))

With this change, I didn't get the memory error. However, there are still many bugs in the code for the new tensorflow.