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.

MLP

General MLP supporting custom last activation, orthogonal init, and output reshape.

EmpiricalNormalizer

Normalize observations with online mean and variance estimates.

build_mlp_from_cfg(module_cfg, in_dim, out_dim)

Construct an MLP from a model configuration.

General neural networks, normalization and network construction.

Classes:

EmpiricalNormalizer

Normalize observations with online mean and variance estimates.

MLP

General MLP supporting custom last activation, orthogonal init, and output reshape.

Functions:

build_mlp_from_cfg(module_cfg, in_dim, out_dim)

Construct an MLP from a model configuration.

class embodichain.learning.models.EmpiricalNormalizer[source]#

Bases: Module

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.

forward(value)[source]#

Return observations normalized by the current running moments.

Return type:

Tensor

update(value)[source]#

Merge one observation batch into the running moments.

Return type:

None

class embodichain.learning.models.MLP[source]#

Bases: Sequential

General MLP supporting custom last activation, orthogonal init, and output reshape.

Parameters:
  • input_dim (int) – input dimension

  • output_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 linear

  • use_layernorm (bool) – whether to add LayerNorm after each hidden linear layer

  • dropout_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.

__init__(input_dim, output_dim, hidden_dims, activation='elu', last_activation=None, use_layernorm=False, dropout_p=0.0)[source]#

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

init_orthogonal(scales=1.0)[source]#

Orthogonal-initialize linear layers and zero the bias.

scales: single gain value or a sequence with length equal to the number of linear layers.

Return type:

None

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 with type="mlp" and network_cfg containing hidden_sizes plus optional activation, normalization, dropout and orthogonal-initialization settings.

  • in_dim (int) – Number of input features.

  • out_dim (int) – Number of output features.

Return type:

MLP

Returns:

Configured MLP module.

MLP and configuration builder#

Trainable MLP shared by supervised learning and RL policy builders.

Classes:

MLP

General MLP supporting custom last activation, orthogonal init, and output reshape.

Functions:

build_mlp_from_cfg(module_cfg, in_dim, out_dim)

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 dimension

  • output_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 linear

  • use_layernorm (bool) – whether to add LayerNorm after each hidden linear layer

  • dropout_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.

__init__(input_dim, output_dim, hidden_dims, activation='elu', last_activation=None, use_layernorm=False, dropout_p=0.0)[source]#

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

init_orthogonal(scales=1.0)[source]#

Orthogonal-initialize linear layers and zero the bias.

scales: single gain value or a sequence with length equal to the number of linear layers.

Return type:

None

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 with type="mlp" and network_cfg containing hidden_sizes plus optional activation, normalization, dropout and orthogonal-initialization settings.

  • in_dim (int) – Number of input features.

  • out_dim (int) – Number of output features.

Return type:

MLP

Returns:

Configured MLP module.

Feature normalization#

Running feature normalization shared by learning models.

Classes:

EmpiricalNormalizer

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.

forward(value)[source]#

Return observations normalized by the current running moments.

Return type:

Tensor

update(value)[source]#

Merge one observation batch into the running moments.

Return type:

None