embodichain.learning.models#
General neural networks and feature normalization#
These components support supervised learning and RL without importing RL,
TensorDict or simulation. build_mlp_from_cfg constructs an MLP from a network
configuration; EmpiricalNormalizer stores feature moments as module buffers.
RL policy interfaces and construction belong to
embodichain.learning.rl.policies.
General MLP supporting custom last activation, orthogonal init, and output reshape. |
|
Normalize observations with online mean and variance estimates. |
|
|
Construct an MLP from a model configuration. |
General neural networks, normalization and network construction.
Classes:
Normalize observations with online mean and variance estimates. |
|
General MLP supporting custom last activation, orthogonal init, and output reshape. |
Functions:
|
Construct an MLP from a model configuration. |
- class embodichain.learning.models.EmpiricalNormalizer[source]#
Bases:
ModuleNormalize observations with online mean and variance estimates.
Statistics are stored as module buffers so checkpoints preserve the exact transformation used during training and evaluation.
- Parameters:
feature_dim (
int) – Number of features in the final observation dimension.epsilon (
float) – Stabilizer added to the running standard deviation.
Methods:
__init__(feature_dim[, epsilon])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(value)Return observations normalized by the current running moments.
update(value)Merge one observation batch into the running moments.
- __init__(feature_dim, epsilon=0.01)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- class embodichain.learning.models.MLP[source]#
Bases:
SequentialGeneral MLP supporting custom last activation, orthogonal init, and output reshape.
- Parameters:
input_dim (
int) – input dimensionoutput_dim (
int|Sequence[int]) – output dimension (int or shape tuple/list)hidden_dims (
Sequence[int]) – hidden layer sizes, e.g. [256, 256]activation (
str|None) – hidden layer activation name (relu/elu/tanh/gelu/silu)last_activation (
str|None) – last-layer activation name or None for linearuse_layernorm (
bool) – whether to add LayerNorm after each hidden linear layerdropout_p (
float) – dropout probability for hidden layers (0 disables)
Methods:
__init__(input_dim, output_dim, hidden_dims)Initialize internal Module state, shared by both nn.Module and ScriptModule.
init_orthogonal([scales])Orthogonal-initialize linear layers and zero the bias.
- embodichain.learning.models.build_mlp_from_cfg(module_cfg, in_dim, out_dim)[source]#
Construct an MLP from a model configuration.
- Parameters:
module_cfg (
Mapping[str,Any]) – Mapping withtype="mlp"andnetwork_cfgcontaininghidden_sizesplus optional activation, normalization, dropout and orthogonal-initialization settings.in_dim (
int) – Number of input features.out_dim (
int) – Number of output features.
- Return type:
- Returns:
Configured MLP module.
MLP and configuration builder#
Trainable MLP shared by supervised learning and RL policy builders.
Classes:
General MLP supporting custom last activation, orthogonal init, and output reshape. |
Functions:
|
Construct an MLP from a model configuration. |
- class embodichain.learning.models.mlp.MLP[source]#
General MLP supporting custom last activation, orthogonal init, and output reshape.
- Parameters:
input_dim (
int) – input dimensionoutput_dim (
int|Sequence[int]) – output dimension (int or shape tuple/list)hidden_dims (
Sequence[int]) – hidden layer sizes, e.g. [256, 256]activation (
str|None) – hidden layer activation name (relu/elu/tanh/gelu/silu)last_activation (
str|None) – last-layer activation name or None for linearuse_layernorm (
bool) – whether to add LayerNorm after each hidden linear layerdropout_p (
float) – dropout probability for hidden layers (0 disables)
Methods:
__init__(input_dim, output_dim, hidden_dims)Initialize internal Module state, shared by both nn.Module and ScriptModule.
init_orthogonal([scales])Orthogonal-initialize linear layers and zero the bias.
- embodichain.learning.models.mlp.build_mlp_from_cfg(module_cfg, in_dim, out_dim)[source]#
Construct an MLP from a model configuration.
- Parameters:
module_cfg (
Mapping[str,Any]) – Mapping withtype="mlp"andnetwork_cfgcontaininghidden_sizesplus optional activation, normalization, dropout and orthogonal-initialization settings.in_dim (
int) – Number of input features.out_dim (
int) – Number of output features.
- Return type:
- Returns:
Configured MLP module.
Feature normalization#
Running feature normalization shared by learning models.
Classes:
Normalize observations with online mean and variance estimates. |
- class embodichain.learning.models.normalizer.EmpiricalNormalizer[source]#
Normalize observations with online mean and variance estimates.
Statistics are stored as module buffers so checkpoints preserve the exact transformation used during training and evaluation.
- Parameters:
feature_dim (
int) – Number of features in the final observation dimension.epsilon (
float) – Stabilizer added to the running standard deviation.
Methods:
__init__(feature_dim[, epsilon])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(value)Return observations normalized by the current running moments.
update(value)Merge one observation batch into the running moments.
- __init__(feature_dim, epsilon=0.01)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.