Skip to content

PPOAgent ​

python
PPOAgent(model: PPOModel, device: torch.device | None = None, observation_batch_shape_hint: tuple[int, ...] | None = None) -> None

Agent for greedy action selection using a PPO model.

Uses the policy head logits for argmax action selection (no sampling). Implements the ActionSelector protocol for use with the Tester.

Initialize the PPOAgent.

Parameters:

  • model (PPOModel) – The PPO model.
  • device (device | None) – The device to run inference on.
  • observation_batch_shape_hint (tuple[int, ...] | None) – Optional maximum batch shape for the reusable CUDA observation buffer.

Source

Methods ​

get_actions ​

python
get_actions(states: np.ndarray, action_masker: ActionMasker | None = None) -> list[int]

Choose greedy actions for a batch of states.

Parameters:

  • states (ndarray) – A batch of state observations with shape (N, *state_shape).
  • action_masker (ActionMasker | None) – Optional ActionMasker for filtering allowed actions.

Returns:

  • list[int] – A list of selected actions (greedy based on policy logits).

Source

Values ​

device ​

python
device = device if device is not None else torch.device('cpu')

Source

model ​

python
model = model

Source