metarl.torch.policies.deterministic_mlp_policy module

This modules creates a deterministic policy network.

A neural network can be used as policy method in different RL algorithms. It accepts an observation of the environment and predicts an action.

class DeterministicMLPPolicy(env_spec, name='DeterministicMLPPolicy', **kwargs)[source]

Bases: metarl.torch.policies.policy.Policy, metarl.torch.modules.mlp_module.MLPModule

Implements a deterministic policy network.

The policy network selects action based on the state of the environment. It uses a PyTorch neural network module to fit the function of pi(s).

get_action(observation)[source]

Get a single action given an observation.

Parameters:observation (np.ndarray) – Observation from the environment.
Returns:
  • np.ndarray: Predicted action.
  • dict:
    • list[float]: Mean of the distribution
    • list[float]: Log of standard deviation of the
      distribution
Return type:tuple
get_actions(observations)[source]

Get actions given observations.

Parameters:observations (np.ndarray) – Observations from the environment.
Returns:
  • np.ndarray: Predicted actions.
  • dict:
    • list[float]: Mean of the distribution
    • list[float]: Log of standard deviation of the
      distribution
Return type:tuple
reset(dones=None)[source]

Reset the environment.

Parameters:dones (numpy.ndarray) – Reset values