unilab.algos.torch.fast_td3.learner

FastTD3 Learner — aligned with reference FastTD3 repository.

Architecture (from reference fast_td3.py): - Actor: ReLU MLP (hidden → hidden//2 → hidden//4 → n_act, Tanh)

  • Per-env noise scales (sampled uniformly, resampled on episode done)

  • Small init scale for output layer

  • Critic: Twin Distributional Q-Networks (C51 variant) - ReLU MLP with num_atoms output

  • Observation normalization with EmpiricalNormalization

  • AdamW optimizer with weight_decay=0.1

  • Cosine LR scheduler

Hyperparameters aligned with reference Go1JoystickFlat config.

Classes

FastTD3Learner

FastTD3 learner aligned with reference FastTD3 repository.

TD3Actor

Deterministic actor with per-environment exploration noise.

class unilab.algos.torch.fast_td3.learner.TD3Actor[source]

Bases: Module

Deterministic actor with per-environment exploration noise.

Architecture: Linear→ReLU → Linear→ReLU → Linear→ReLU → Linear→Tanh Each environment has its own noise scale, sampled uniformly in [std_min, std_max]. Noise scales are resampled when an episode ends.

Parameters:
noise_scales: torch.Tensor
log_std_min: torch.Tensor
log_std_max: torch.Tensor
__init__(obs_dim, n_act, num_envs, init_scale, hidden_dim, log_std_min=-3.0, log_std_max=0.0, device=None)[source]

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

Parameters:
forward(obs)[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 (Tensor)

Return type:

Tensor

explore(obs, dones=None, deterministic=False)[source]

Forward pass with per-env exploration noise.

Parameters:
Return type:

Tensor

class unilab.algos.torch.fast_td3.learner.FastTD3Learner[source]

Bases: object

FastTD3 learner aligned with reference FastTD3 repository.

Key hyperparameters (from Go1JoystickFlat): - gamma=0.97, tau=0.1 - AdamW with weight_decay=0.1 - Cosine LR schedule - Distributional critic (C51, num_atoms=101, v_min/max=±10) - CDQ (Clipped Double Q-learning) toggle - Observation normalization

Parameters:
__init__(obs_dim, action_dim, critic_obs_dim, num_envs=1024, device='cpu', gamma=0.97, tau=0.01, actor_lr=0.0003, critic_lr=0.0003, actor_hidden_dim=512, critic_hidden_dim=1024, num_atoms=101, v_min=-10.0, v_max=10.0, init_scale=0.01, log_std_min=-3.0, log_std_max=0.0, weight_decay=0.001, use_cdq=True, policy_noise=0.1, noise_clip=0.2, policy_frequency=2, max_iterations=50000, obs_normalization=True)[source]
Parameters:
normalize_obs(obs, update=False)[source]

Normalize observations using running statistics.

Parameters:
Return type:

Tensor

update_critic(data)[source]

One critic update step.

Parameters:

data (Dict[str, Tensor])

Return type:

Dict[str, float]

update_actor(data)[source]

One actor update step.

Parameters:

data (Dict[str, Tensor])

Return type:

Dict[str, float]

soft_update_target()[source]

Polyak-average update of critic target network only (matching reference FastTD3).

Return type:

None

soft_update()[source]

Backward-compatible alias for older call sites.

Return type:

None

get_state_dict()[source]
Return type:

Dict

load_state_dict(state_dict)[source]
Parameters:

state_dict (Dict)

Return type:

None