shredx.modules.mlp.MLPEncoder#
- class shredx.modules.mlp.MLPEncoder(input_size: int, hidden_size: int, num_layers: int, dropout: float, device: str = 'cpu')#
Bases:
ModuleMulti-layer perceptron (MLP) encoder.
Creates a feed-forward neural network with identical layer sizes. Uses ReLU activations between layers and applies dropout after the final layer.
- 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.
- devicestr, optional
Device on which to place the module. Default is
"cpu".
Methods
forward(x)Apply the MLP encoder to an input batch.
Notes
Class Methods:
forward(x):
Applies the MLP encoder to an input batch.
- 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)andNonefor no auxiliary losses.