shredx.modules.mlp.SINDyLossMLPEncoder#

class shredx.modules.mlp.SINDyLossMLPEncoder(input_size: int, hidden_size: int, num_layers: int, dropout: float, dt: float, sindy_loss_threshold: float, device: str = 'cpu', **kwargs)#

Bases: SINDyLossMixin, MLPEncoder

MLP encoder with SINDy loss regularization.

Combines a standard MLP encoder with SINDy-based regularization that encourages the hidden state dynamics to follow a sparse polynomial ODE.

Parameters:
input_sizeint

Input feature dimension.

hidden_sizeint

Hidden state dimension.

num_layersint

Number of stacked MLP layers.

dropoutfloat

Dropout probability applied to the outputs.

dtfloat

Time step for SINDy derivatives.

sindy_loss_thresholdfloat

Threshold for coefficient sparsification.

devicestr, optional

Device on which to place the module. Default is "cpu".

**kwargs

Additional keyword arguments passed for compatibility but ignored.

Methods

forward(x)

Apply the SINDy Loss MLP encoder to an input batch.

Notes

Class Methods:

forward(x):

  • Processes input through the MLP and computes SINDy loss based on how well hidden state transitions follow learned dynamics.

  • Parameters:
    • x : Float[torch.Tensor, "batch sequence input_size"]. Input tensor.

  • Returns:
    • tuple. Tuple containing the final output tensor of shape (batch_size, 1, 1, hidden_size) and a dictionary of auxiliary losses.