unilab.algos.torch.flash_sac.layers¶
FlashSAC layers and lightweight normalization helpers.
Functions
Stable log|det J_tanh(x)| term. |
Classes
BatchNorm variant with normalized affine parameters. |
|
Linear layer with post-step weight normalization. |
|
RMSNorm with unit-length scale vector. |
- unilab.algos.torch.flash_sac.layers.safe_tanh_log_det_jacobian(x)[source]¶
Stable log|det J_tanh(x)| term.
- class unilab.algos.torch.flash_sac.layers.UnitLinear[source]¶
Bases:
ModuleLinear layer with post-step weight normalization.
- __init__(input_dim, output_dim)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.UnitBatchNorm[source]¶
Bases:
ModuleBatchNorm variant with normalized affine parameters.
- running_mean: torch.Tensor¶
- running_var: torch.Tensor¶
- __init__(input_dim, momentum=0.01, eps=1e-05)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.UnitRMSNorm[source]¶
Bases:
ModuleRMSNorm with unit-length scale vector.
- __init__(input_dim, eps=1e-06)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.FlashSACEmbedder[source]¶
Bases:
Module- __init__(input_dim, hidden_dim)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.FlashSACBlock[source]¶
Bases:
Module- __init__(hidden_dim, expansion=4)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.NormalTanhPolicy[source]¶
Bases:
Module- __init__(hidden_dim, action_dim, log_std_min=-10.0, log_std_max=2.0)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleUnitLinear[source]¶
Bases:
Module- __init__(num_ensemble, input_dim, output_dim)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleUnitBatchNorm[source]¶
Bases:
Module- running_mean: torch.Tensor¶
- running_var: torch.Tensor¶
- __init__(num_ensemble, input_dim, momentum=0.01, eps=1e-05)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleUnitRMSNorm[source]¶
Bases:
Module- __init__(num_ensemble, input_dim, eps=1e-06)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleFlashSACEmbedder[source]¶
Bases:
Module- __init__(num_ensemble, input_dim, hidden_dim)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleFlashSACBlock[source]¶
Bases:
Module- __init__(num_ensemble, hidden_dim, expansion=4)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, training)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class unilab.algos.torch.flash_sac.layers.EnsembleCategoricalValue[source]¶
Bases:
Module- support: torch.Tensor¶
- __init__(num_ensemble, hidden_dim, num_bins, min_v, max_v)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.