Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get name / id of a OpenAI Gym environment

Given:

import gym
env = gym.make('CartPole-v0')

How do I get CartPole-v0 in a way that works across any Gym env?

like image 932
Andrew Schreiber Avatar asked Oct 12 '18 07:10

Andrew Schreiber


People also ask

How do you cite the OpenAI gym?

Citation in APA styleBrockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., & Zaremba, W. (2016). Openai gym. ArXiv Preprint ArXiv:1606.01540.

What is an environment in OpenAI gym?

OpenAI gym is an environment for developing and testing learning agents. It is focused and best suited for reinforcement learning agent but does not restricts one to try other methods such as hard coded game solver / other deep learning approaches.

Does OpenAI gym use GPU?

This is because GPUs are used for policy training and not running the OpenAI Gym environment instances, thus they are not mandatory (although having a GPU node can assist the agent training by reducing training time).


1 Answers

Unwrap the environment and get the id from the spec

name = env.unwrapped.spec.id

print(name)
# 'CartPole-v0'

In vectorized environments, access the first sub-environment:

name = env.envs[0].unwrapped.spec.id
like image 131
Andrew Schreiber Avatar answered Sep 18 '22 17:09

Andrew Schreiber