garage.np.policies.policy

Base class for policies based on numpy.

class Policy[source]

Bases: abc.ABC

Inheritance diagram of garage.np.policies.policy.Policy

Base class for policies based on numpy.

abstract get_action(self, observation)[source]

Get action sampled from the policy.

Parameters

observation (np.ndarray) – Observation from the environment.

Returns

Actions and extra agent

infos.

Return type

Tuple[np.ndarray, dict[str,np.ndarray]]

abstract get_actions(self, observations)[source]

Get actions given observations.

Parameters

observations (torch.Tensor) – Observations from the environment.

Returns

Actions and extra agent

infos.

Return type

Tuple[np.ndarray, dict[str,np.ndarray]]

reset(self, 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.

property name(self)

Name of policy.

Returns

Name of policy

Return type

str

property env_spec(self)

Policy environment specification.

Returns

Environment specification.

Return type

garage.EnvSpec

property observation_space(self)

Observation space.

Returns

The observation space of the environment.

Return type

akro.Space

property action_space(self)

Action space.

Returns

The action space of the environment.

Return type

akro.Space