garage.np.policies
¶
Policies which use NumPy as a numerical backend.
- class FixedPolicy(env_spec, scripted_actions, agent_infos=None)[source]¶
Bases:
garage.np.policies.policy.Policy
Policy that performs a fixed sequence of actions.
- Parameters
- property env_spec¶
Policy environment specification.
- Returns
Environment specification.
- Return type
- 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
- reset(do_resets=None)[source]¶
Reset policy.
- Parameters
do_resets (None or list[bool]) – Vectorized policy states to reset.
- Raises
ValueError – If do_resets has length greater than 1.
- get_action(observation)[source]¶
Get next action.
- Parameters
observation (np.ndarray) – Ignored.
- Raises
ValueError – If policy is currently vectorized (reset was called with more than one done value).
- Returns
- The action and agent_info
for this time step.
- Return type
- class Policy[source]¶
Bases:
abc.ABC
Base class for policies based on numpy.
- property env_spec¶
Policy environment specification.
- Returns
Environment specification.
- Return type
- 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
- reset(do_resets=None)[source]¶
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.
- class ScriptedPolicy(scripted_actions, agent_env_infos=None)[source]¶
Bases:
garage.np.policies.policy.Policy
Simulates a garage policy object.
- Parameters
- property env_spec¶
Policy environment specification.
- Returns
Environment specification.
- Return type
- 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
- 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.
- class UniformRandomPolicy(env_spec)[source]¶
Bases:
garage.np.policies.policy.Policy
Action taken is uniformly random.
- Parameters
env_spec (EnvSpec) – Environment spec to explore.
- property env_spec¶
Policy environment specification.
- Returns
Environment specification.
- Return type
- 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
- reset(do_resets=None)[source]¶
Reset the state of the exploration.
- Parameters
do_resets (List[bool] or numpy.ndarray or None) – Which vectorization states to reset.