Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: '__flags' #50

Open
jdmartin86 opened this issue Apr 16, 2018 · 4 comments
Open

KeyError: '__flags' #50

jdmartin86 opened this issue Apr 16, 2018 · 4 comments

Comments

@jdmartin86
Copy link

jdmartin86 commented Apr 16, 2018

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
Copy link

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
Copy link
Author

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
Copy link

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.

rt1shnik added a commit to rt1shnik/DQN-atari that referenced this issue May 24, 2018
@dwsmith1983
Copy link

dwsmith1983 commented Jun 19, 2018

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants