unilab.algos.torch.common.networks

Neural network architectures for RL algorithms.

Classes

Critic

Twin distributional Q-networks for off-policy RL (SAC/TD3).

DistributionalQNetwork

Single distributional Q-network (C51 variant).

class unilab.algos.torch.common.networks.DistributionalQNetwork[source]

Bases: Module

Single distributional Q-network (C51 variant).

Architecture: Linear→ReLU → Linear→ReLU → Linear→ReLU → Linear Outputs num_atoms logits over the value distribution.

Parameters:
__init__(obs_dim, n_act, num_atoms, v_min, v_max, hidden_dim, device=None)[source]

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

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

projection(obs, actions, rewards, bootstrap, discount, q_support, device)[source]

Categorical projection (Bellman update on the distribution support).

Parameters:
Return type:

Tensor

class unilab.algos.torch.common.networks.Critic[source]

Bases: Module

Twin distributional Q-networks for off-policy RL (SAC/TD3).

Parameters:
q_support: torch.Tensor
__init__(obs_dim, n_act, num_atoms, v_min, v_max, hidden_dim, device=None)[source]

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

Parameters:
forward(obs, actions)[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:
projection(obs, actions, rewards, bootstrap, discount)[source]

Projection operation using both Q-networks.

Parameters:
get_value(probs)[source]

Calculate value from probability distribution using support.

Parameters:

probs (Tensor)

Return type:

Tensor