Kautenja / playing-mario-with-deep-reinforcement-learning

An implementation of (Double/Dueling) Deep-Q Learning to play Super Mario Bros.
MIT License
68 stars 12 forks source link

No registered env with id: DeepQAgentNoFrameskip-v10 #34

Closed Ameyapores closed 6 years ago

Ameyapores commented 6 years ago

@Kautenja - Firstly, great to see your repositories. Reflects the amount of time and efforts invested.

I have followed your documentation and have trained a deep_q_agent in the 'SuperMarioBros-v0'-env Id. Accordingly, there's a saved file in weights.h5 file in the results directory. But there seems to be some issue in the play.py file (src).

Whenever I try to import weights.h5 using the path as you mention through the following command- python . -m play -o results/SuperMarioBros-v0/DeepQAgent/2018-08-11_12-54/ following error pops up.

pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html /home/ameya/.env/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. Traceback (most recent call last): File "/home/ameya/.env/lib/python3.6/site-packages/gym/envs/registration.py", line 143, in spec return self.env_specs[id] KeyError: 'DeepQAgentNoFrameskip-v10'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "./main.py", line 8, in main() File "./src/cli.py", line 52, in main results_dir=args.output File "./src/play.py", line 58, in play env = build_atari_environment(env_id, is_validation=True) File "./src/environment/atari.py", line 43, in build_atari_environment env = gym.make('{}NoFrameskip-v10'.format(game_name)) File "/home/ameya/.env/lib/python3.6/site-packages/gym/envs/registration.py", line 167, in make return registry.make(id) File "/home/ameya/.env/lib/python3.6/site-packages/gym/envs/registration.py", line 118, in make spec = self.spec(id) File "/home/ameya/.env/lib/python3.6/site-packages/gym/envs/registration.py", line 153, in spec raise error.UnregisteredEnv('No registered env with id: {}'.format(id)) gym.error.UnregisteredEnv: No registered env with id: DeepQAgentNoFrameskip-v10

Has this error been encountered previously?

Kautenja commented 6 years ago

Hmm, I had not encountered this error until now, but believe I have solved the issue. In the command

python . -m play -o results/SuperMarioBros-v0/DeepQAgent/2018-08-11_12-54/

there is a / at the very end of the line. This results in a call to .split('/') returning a list with an extra, empty string at the last index that messes up some parsing logic. I've changed this code to ignore these empty strings and confirmed that the command works so you should be good to go now! Thanks for catching this issue! Closing, as I believe it to be resolved.