rlightning.policy.simple_ppo_policy

class rlightning.policy.simple_ppo_policy.SimplePPOPolicy(config: PolicyConfig, role_type: PolicyRole)[source]

Bases: BasePolicy

A simple PPO Policy with a CNN encoder for testing purposes. it takes the actor-critic architecture.

construct_network(env_meta, *args, **kwargs)[source]

Construct the neural network architecture.

Parameters:
  • env_meta – Environment metadata for network configuration.

  • *args – Variable positional arguments.

  • **kwargs – Variable keyword arguments.

evaluate(obs, action)[source]
get_action(obs: MockModule('torch.Tensor'))[source]
get_action_value(obs)[source]
get_trainable_parameters()[source]

Return a dict of module state dicts.

get_value(obs: MockModule('torch.Tensor'))[source]

Compute state value

Parameters:

obs (torch.Tensor) – Batched observation array

Returns:

Batched state value

Return type:

torch.Tensor

load_state_dict(state_dict, strict=True, assign=False)[source]

Load trainable parameters from state_dict.

postprocess(data)[source]
rollout_step(env_ret: EnvRet) PolicyResponse[source]
save_weights(save_dir: str, epoch: int)[source]
setup_optimizer(optim_cfg)[source]

Set up the optimizer for training.

Parameters:

optim_cfg – Optimizer configuration.

train()[source]

Run a training step for the policy.

update_dataset(data)[source]

Update the dataset in the policy by getting a batch from the buffer.

Submodules