gym_loop module

Top-level package for Gym Loop.

gym_loop cli

Usage: gym-loop [OPTIONS] COMMAND [ARGS]…

Console script for gym-loop.

Commands:

create-default Produce default run config for the agent and loop…

eval Evaluate agent specified in run config without updating

train Run agent training experiment specified in run config

gym_loop main module

gym_loop.gym_loop.build_agent(params, policy, env)[source]

Create agent from run parameters

gym_loop.gym_loop.build_env(params)[source]

Create gym env from run parameters

gym_loop.gym_loop.build_loop(params, agent, policy, env)[source]

Create loop from run parameters

gym_loop.gym_loop.build_policy(params, env)[source]
gym_loop.gym_loop.eval_agent(run_params)[source]

Run loop without updating agent

Args:
run_params(dict) Dictionary from parsed configuration file
gym_loop.gym_loop.get_default_params(agent_str, loop_str)[source]

Build a dict with default run spec for the agent

Args:
loop_str (str): loop module class string of format ‘package.module:class’ or ‘loop_filepath:class’ agent_str (str): agent module class string of format ‘package.module:class’ or ‘agent_filepath:class’
Returns:
dict: default run spec dict
gym_loop.gym_loop.module_str_to_class(module_str)[source]

Parse module class string to a class

Args:
module_str(str) Dictionary from parsed configuration file
Returns:
type: class
gym_loop.gym_loop.train_agent(run_params)[source]

Run training loop for run parameters

Args:
run_params(dict) Dictionary from parsed configuration file
gym_loop.gym_loop.validate_module_str(module_str)[source]

Check if string is module class string

Args:
module_str(str) A string to test
Returns:
bool: Is module class string valid

gym_loop loops

class gym_loop.loops.base_loop.BaseLoop(**params)[source]

Bases: object

evaluate()[source]
static get_default_parameters()[source]
train()[source]
class gym_loop.loops.default_loop.DefaultLoop(agent, env, **params)[source]

Bases: gym_loop.loops.base_loop.BaseLoop

evaluate()[source]
static get_default_parameters()[source]

Get default parameter dictionary for the loop

train()[source]

Training loop

gym_loop agents

class gym_loop.agents.base_agent.BaseAgent(**params)[source]

Bases: object

act(state: numpy.ndarray, episode_num: int)[source]

Retrieves agent’s action upon state

static get_default_parameters() → Dict[KT, VT][source]

Specifies tweakable parameters for agents

Returns:
dict: default parameters for the agent
static get_default_policy() → Dict[KT, VT][source]

Specifies default policy to use with agent

Returns:
dict: class string and parameters for the policy
memorize(last_ob: numpy.ndarray, action: numpy.ndarray, reward: numpy.ndarray, done: numpy.ndarray, ob: numpy.ndarray)[source]

Called after environment steps on action, arguments are classic SARSA tuple

metrics(episode_num: int) → Dict[KT, VT][source]

Returns dict with metrics to log in tensorboard

update(episode_num: int)[source]

Called immediately after memorize

class gym_loop.agents.random_agent.RandomAgent(**params)[source]

Bases: gym_loop.agents.base_agent.BaseAgent

act(state, episode_num)[source]

Retrieves agent’s action upon state

static get_default_parameters()[source]

Specifies tweakable parameters for agents

Returns:
dict: default parameters for the agent
memorize(last_ob: numpy.ndarray, action: numpy.ndarray, reward: numpy.ndarray, done: numpy.ndarray, ob: numpy.ndarray, global_step: int)[source]

Called after environment steps on action, arguments are classic SARSA tuple

metrics(episode_num)[source]

Returns dict with metrics to log in tensorboard

update(episode_num)[source]

Called immediately after memorize