garage.torch.policies.policy
¶
Base Policy.
-
class
Policy
(env_spec, name)¶ Bases:
torch.nn.Module
,garage.np.policies.Policy
,abc.ABC
Policy base class.
Parameters: -
env_spec
¶ Policy environment specification.
Returns: Environment specification. Return type: garage.EnvSpec
-
observation_space
¶ Observation space.
Returns: The observation space of the environment. Return type: akro.Space
-
action_space
¶ Action space.
Returns: The action space of the environment. Return type: akro.Space
-
get_action
(self, observation)¶ Get action sampled from the policy.
Parameters: observation (np.ndarray) – Observation from the environment. Returns: - Action and extra agent
- info.
Return type: Tuple[np.ndarray, dict[str,np.ndarray]]
-
get_actions
(self, observations)¶ Get actions given observations.
Parameters: observations (np.ndarray) – Observations from the environment. Returns: - Actions and extra agent
- infos.
Return type: Tuple[np.ndarray, dict[str,np.ndarray]]
-
get_param_values
(self)¶ Get the parameters to the policy.
This method is included to ensure consistency with TF policies.
Returns: The parameters (in the form of the state dictionary). Return type: dict
-
set_param_values
(self, state_dict)¶ Set the parameters to the policy.
This method is included to ensure consistency with TF policies.
Parameters: state_dict (dict) – State dictionary.
-
reset
(self, 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.
-