unilab.algos.torch.hora.models

Functions

build_hora_shared_actor_critic(*, obs_dim, ...)

Build the shared HORA core from actor/critic config without mutating inputs.

Classes

HoraActorModel

HoraCoreOutput

HoraCoreOutput(policy_obs: 'torch.Tensor', trunk_latent: 'torch.Tensor', privileged_latent: 'torch.Tensor', privileged_target: 'torch.Tensor')

HoraCriticModel

HoraSharedActorCritic

Shared-backbone HORA actor-critic with optional adaptation encoder.

ProprioAdaptTConv

Temporal adaptation encoder used by HORA stage-2 distillation.

class unilab.algos.torch.hora.models.ProprioAdaptTConv[source]

Bases: Module

Temporal adaptation encoder used by HORA stage-2 distillation.

Parameters:
  • frame_dim (int)

  • latent_dim (int)

__init__(frame_dim, latent_dim)[source]

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

Parameters:
  • frame_dim (int)

  • latent_dim (int)

forward(proprio_hist)[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:

proprio_hist (Tensor)

Return type:

Tensor

class unilab.algos.torch.hora.models.HoraCoreOutput[source]

Bases: object

HoraCoreOutput(policy_obs: ‘torch.Tensor’, trunk_latent: ‘torch.Tensor’, privileged_latent: ‘torch.Tensor’, privileged_target: ‘torch.Tensor’)

Parameters:
policy_obs: Tensor
trunk_latent: Tensor
privileged_latent: Tensor
privileged_target: Tensor
__init__(policy_obs, trunk_latent, privileged_latent, privileged_target)
Parameters:
class unilab.algos.torch.hora.models.HoraSharedActorCritic[source]

Bases: Module

Shared-backbone HORA actor-critic with optional adaptation encoder.

Parameters:
__init__(obs_dim, action_dim, *, priv_info_dim, priv_info_embed_dim=8, actor_hidden_dims=(512, 256, 128), priv_mlp_hidden_dims=(256, 128, 8), activation='elu', obs_normalization=False, distribution_cfg=None, use_student_encoder=False, proprio_hist_len=30, proprio_frame_dim=None)[source]

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

Parameters:
update_normalization(obs)[source]
Parameters:

obs (TensorDict)

Return type:

None

encode_privileged_info(priv_info)[source]
Parameters:

priv_info (Tensor | None)

Return type:

Tensor

encode_proprio_history(proprio_hist)[source]
Parameters:

proprio_hist (Tensor)

Return type:

Tensor

build_core_output(obs, *, prefer_student)[source]
Parameters:
  • obs (TensorDict)

  • prefer_student (bool)

Return type:

HoraCoreOutput

trunk_latent_from_tensors(actor_obs, priv_info, *, prefer_student, proprio_hist=None)[source]

Tensor-only HORA trunk path used by APPO compiled minibatch loss.

Parameters:
Return type:

Tensor

policy_mean_from_tensors(actor_obs, priv_info, *, prefer_student, proprio_hist=None)[source]
Parameters:
Return type:

Tensor

value_from_tensors(actor_obs, priv_info, *, prefer_student, proprio_hist=None)[source]
Parameters:
Return type:

Tensor

policy_mean(obs, *, prefer_student)[source]
Parameters:
  • obs (TensorDict)

  • prefer_student (bool)

Return type:

tuple[Tensor, HoraCoreOutput]

value(obs, *, prefer_student)[source]
Parameters:
  • obs (TensorDict)

  • prefer_student (bool)

Return type:

tuple[Tensor, HoraCoreOutput]

unilab.algos.torch.hora.models.build_hora_shared_actor_critic(*, obs_dim, action_dim, priv_info_dim, actor_cfg=None, critic_cfg=None)[source]

Build the shared HORA core from actor/critic config without mutating inputs.

Parameters:
Return type:

HoraSharedActorCritic

class unilab.algos.torch.hora.models.HoraActorModel[source]

Bases: Module

Parameters:
is_recurrent: bool = False
__init__(obs, obs_groups, obs_set, output_dim, *, shared_model=None, hidden_dims=(512, 256, 128), activation='elu', obs_normalization=False, distribution_cfg=None, priv_info_dim=None, priv_info_embed_dim=8, priv_mlp_hidden_dims=(256, 128, 8), use_student_encoder=False, proprio_hist_len=30, proprio_frame_dim=None)[source]

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

Parameters:
forward(obs, masks=None, hidden_state=None, stochastic_output=False)[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:
Return type:

Tensor

reset(dones=None, hidden_state=None)[source]
Parameters:

dones (Tensor | None)

Return type:

None

get_hidden_state()[source]
detach_hidden_state(dones=None)[source]
Parameters:

dones (Tensor | None)

Return type:

None

property distribution: rsl_rl.modules.GaussianDistribution
property output_mean: Tensor
property output_std: Tensor
property output_entropy: Tensor
property output_distribution_params: tuple[Tensor, ...]
get_output_log_prob(outputs)[source]
Parameters:

outputs (Tensor)

Return type:

Tensor

get_kl_divergence(old_params, new_params)[source]
Parameters:
Return type:

Tensor

update_normalization(obs)[source]
Parameters:

obs (TensorDict)

Return type:

None

as_jit()[source]
Return type:

Module

as_onnx(verbose)[source]
Parameters:

verbose (bool)

Return type:

Module

class unilab.algos.torch.hora.models.HoraCriticModel[source]

Bases: Module

Parameters:
is_recurrent: bool = False
__init__(obs, obs_groups, obs_set, output_dim, *, shared_model=None, hidden_dims=(512, 256, 128), activation='elu', obs_normalization=False, priv_info_dim=None, priv_info_embed_dim=8, priv_mlp_hidden_dims=(256, 128, 8))[source]

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

Parameters:
forward(obs, masks=None, hidden_state=None, stochastic_output=False)[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:
Return type:

Tensor

reset(dones=None, hidden_state=None)[source]
Parameters:

dones (Tensor | None)

Return type:

None

get_hidden_state()[source]
detach_hidden_state(dones=None)[source]
Parameters:

dones (Tensor | None)

Return type:

None

update_normalization(obs)[source]
Parameters:

obs (TensorDict)

Return type:

None