In [1]:
import numpy as np
import gym
In [2]:
def init_gym(env_name):
"""
:param env_name: str, OpenAI Gym environment name
:return: 3-tuple
env: ai gym environment
obs_dim: observation dimensions
act_dim: action dimensions
"""
env = gym.make(env_name)
obs_dim = env.observation_space.shape[0]
act_dim = env.action_space.shape[0]
obs_dim += 1
return env, obs_dim, act_dim
In [3]:
env_names = ['InvertedPendulum-v1', 'InvertedDoublePendulum-v1', 'Reacher-v1',
'HalfCheetah-v1', 'Swimmer-v1', 'Hopper-v1', 'Walker2d-v1',
'Ant-v1', 'Humanoid-v1', 'HumanoidStandup-v1']
In [4]:
dims = []
for env_name in env_names:
env, obs_dim, act_dim = init_gym(env_name)
dims.append((obs_dim, act_dim))
In [5]:
names_dims = list(zip(env_names, dims))
for name_dim in names_dims:
print('{}: obs_dim: {}, act_dim: {}'.format(name_dim[0], name_dim[1][0], name_dim[1][1]))
In [ ]: