bc_point_deterministic_policy
¶
Example of using Behavioral Cloning.
- class OptimalPolicy(env_spec, goal)¶
Bases:
garage.torch.policies.Policy
Optimal policy for PointEnv.
- Parameters
env_spec (EnvSpec) – The environment spec.
goal (np.ndarray) – The goal location of the environment.
- 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
- get_action(observation)¶
Get action given observation.
- Parameters
observation (np.ndarray) – Observation from PointEnv. Should have length at least 2.
- Returns
np.ndarray: Optimal action in the environment. Has length 2.
dict[str, np.ndarray]: Agent info (empty).
- Return type
- get_actions(observations)¶
Get actions given observations.
- Parameters
observations (np.ndarray) – Observations from the environment. Has shape \((B, O)\), where \(B\) is the batch dimension and \(O\) is the observation dimensionality (at least 2).
- Returns
- np.ndarray: Batch of optimal actions.
Has shape \((B, 2)\), where \(B\) is the batch dimension.
Optimal action in the environment. * dict[str, np.ndarray]: Agent info (empty).
- Return type
- get_param_values()¶
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
- set_param_values(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(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.
- bc_point(ctxt=None)¶
Run Behavioral Cloning on garage.envs.PointEnv.
- Parameters
ctxt (ExperimentContext) – Provided by wrap_experiment.