garage.np.policies.scripted_policy

Simulates a garage policy object.

class ScriptedPolicy(scripted_actions, agent_env_infos=None)[source]

Bases: garage.np.policies.policy.Policy

Inheritance diagram of garage.np.policies.scripted_policy.ScriptedPolicy

Simulates a garage policy object.

Parameters
  • scripted_actions (list or dictionary) – data structure indexed by observation, returns a corresponding action

  • agent_env_infos (list or dictionary) – data structure indexed by observation, returns a corresponding agent_env_info

property name

Name of policy.

Returns

Name of policy

Return type

str

property env_spec

Policy environment specification.

Returns

Environment specification.

Return type

garage.EnvSpec

property observation_space

Observation space.

Returns

The observation space of the environment.

Return type

akro.Space

property action_space

Action space.

Returns

The action space of the environment.

Return type

akro.Space

set_param_values(params)[source]

Set param values.

Parameters

params (np.ndarray) – A numpy array of parameter values.

get_param_values()[source]

Get param values.

Returns

Values of the parameters evaluated in

the current session

Return type

np.ndarray

get_action(observation)[source]

Return a single action.

Parameters

observation (numpy.ndarray) – Observations.

Returns

Action given input observation. dict[dict]: Agent infos indexed by observation.

Return type

int

get_actions(observations)[source]

Return multiple actions.

Parameters

observations (numpy.ndarray) – Observations.

Returns

Actions given input observations. dict[dict]: Agent info indexed by observation.

Return type

list[int]

reset(do_resets=None)

Reset the policy.

This is effective only to recurrent policies.

do_resets is an array of boolean indicating which internal states to be reset. The length of do_resets should be equal to the length of inputs, i.e. batch size.

Parameters

do_resets (numpy.ndarray) – Bool array indicating which states to be reset.