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))


[2017-07-22 06:35:06,733] Making new env: InvertedPendulum-v1
[2017-07-22 06:35:06,974] Making new env: InvertedDoublePendulum-v1
[2017-07-22 06:35:06,979] Making new env: Reacher-v1
[2017-07-22 06:35:06,988] Making new env: HalfCheetah-v1
[2017-07-22 06:35:06,997] Making new env: Swimmer-v1
[2017-07-22 06:35:07,003] Making new env: Hopper-v1
[2017-07-22 06:35:07,012] Making new env: Walker2d-v1
[2017-07-22 06:35:07,019] Making new env: Ant-v1
[2017-07-22 06:35:07,030] Making new env: Humanoid-v1
[2017-07-22 06:35:07,037] Making new env: HumanoidStandup-v1

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]))


InvertedPendulum-v1: obs_dim: 5, act_dim: 1
InvertedDoublePendulum-v1: obs_dim: 12, act_dim: 1
Reacher-v1: obs_dim: 12, act_dim: 2
HalfCheetah-v1: obs_dim: 18, act_dim: 6
Swimmer-v1: obs_dim: 9, act_dim: 2
Hopper-v1: obs_dim: 12, act_dim: 3
Walker2d-v1: obs_dim: 18, act_dim: 6
Ant-v1: obs_dim: 112, act_dim: 8
Humanoid-v1: obs_dim: 377, act_dim: 17
HumanoidStandup-v1: obs_dim: 377, act_dim: 17

In [ ]: