unilab.algos.torch.him_ppo

class unilab.algos.torch.him_ppo.HIMActorCritic[source]

Bases: Module

Parameters:
is_recurrent = False
__init__(num_actor_obs, num_critic_obs, num_one_step_obs, num_actions, actor_hidden_dims=(512, 256, 128), critic_hidden_dims=(512, 256, 128), activation='elu', init_noise_std=1.0, estimator=None)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:
property action_mean: Tensor
property action_std: Tensor
property entropy: Tensor
reset(dones=None)[source]
Parameters:

dones (Tensor | None)

Return type:

None

forward()[source]

Define the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tensor

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

update_distribution(obs_history)[source]
Parameters:

obs_history (Tensor)

Return type:

None

act(obs_history, **kwargs)[source]
Parameters:

obs_history (Tensor)

Return type:

Tensor

get_actions_log_prob(actions)[source]
Parameters:

actions (Tensor)

Return type:

Tensor

act_inference(obs_history, observations=None)[source]
Parameters:

obs_history (Tensor)

Return type:

Tensor

evaluate(critic_observations, **kwargs)[source]
Parameters:

critic_observations (Tensor)

Return type:

Tensor

class unilab.algos.torch.him_ppo.HIMPPO[source]

Bases: object

Parameters:
__init__(actor_critic, num_learning_epochs=1, num_mini_batches=1, clip_param=0.2, gamma=0.998, lam=0.95, value_loss_coef=1.0, entropy_coef=0.0, learning_rate=0.001, max_grad_norm=1.0, use_clipped_value_loss=True, schedule='fixed', desired_kl=0.01, device='cpu', **kwargs)[source]
Parameters:
actor_critic: HIMActorCritic
init_storage(num_envs, num_transitions_per_env, actor_obs_shape, critic_obs_shape, action_shape)[source]
Parameters:
  • num_envs (int)

  • num_transitions_per_env (int)

Return type:

None

test_mode()[source]
Return type:

None

train_mode()[source]
Return type:

None

act(obs, critic_obs)[source]
Parameters:
Return type:

Tensor

process_env_step(next_obs, rewards, dones, extras)[source]
Parameters:
Return type:

None

compute_returns(last_critic_obs)[source]
Parameters:

last_critic_obs (Tensor)

Return type:

None

update()[source]
Return type:

tuple[float, float, float, float]

class unilab.algos.torch.him_ppo.HIMEstimator[source]

Bases: Module

Parameters:
__init__(temporal_steps, num_one_step_obs, enc_hidden_dims=(128, 64, 16), tar_hidden_dims=(128, 64), activation='elu', learning_rate=0.001, max_grad_norm=10.0, num_prototype=32, temperature=3.0, velocity_target_start=None, target_obs_start=3)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Parameters:
get_latent(obs_history)[source]
Parameters:

obs_history (Tensor)

Return type:

tuple[Tensor, Tensor]

forward(obs_history)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

obs_history (Tensor)

Return type:

tuple[Tensor, Tensor]

encode(obs_history)[source]
Parameters:

obs_history (Tensor)

Return type:

tuple[Tensor, Tensor]

update(obs_history, next_critic_obs, lr=None)[source]
Parameters:
Return type:

tuple[float, float]

class unilab.algos.torch.him_ppo.HIMRolloutStorage[source]

Bases: object

Parameters:
class Transition[source]

Bases: object

__init__()[source]
clear()[source]
Return type:

None

__init__(num_envs, num_transitions_per_env, obs_shape, privileged_obs_shape, actions_shape, device='cpu')[source]
Parameters:
add_transition(transition)[source]
Parameters:

transition (Transition)

Return type:

None

add_transitions(transition)[source]
Parameters:

transition (Transition)

Return type:

None

clear()[source]
Return type:

None

compute_returns(last_values, gamma, lam)[source]
Parameters:
Return type:

None

mini_batch_generator(num_mini_batches, num_epochs=8)[source]
Parameters:
  • num_mini_batches (int)

  • num_epochs (int)

Modules