mlp

MLP & its config.

class cneuromax.fitting.deeplearning.litmodule.nnmodule.mlp.MLPConfig(dims='???', p_dropout=0.0)[source]

Bases: object

Holds MLP config values.

Parameters:
  • dims (list[int], default: '???') – List of dimensions for each layer.

  • p_dropout (float, default: 0.0) – Dropout probability.

class cneuromax.fitting.deeplearning.litmodule.nnmodule.mlp.MLP(config, activation_fn)[source]

Bases: Module

Multi-layer perceptron (MLP).

Allows for a variable number of layers, activation functions, and dropout probability.

Parameters:
model

The internal torch.nn.Module that holds the MLP’s layers.

Type:

torch.nn.Sequential

forward(x)[source]

Flattens input’s dimensions and passes it through the model.

Note

This MLP is currently only capable of returning 1D torch.Tensor batches.

TODO: Add support for returning 2D+ torch.Tensor batches.

Parameters:

x (Float[Tensor, 'batch_size *d_input']) – The input data batch.

Return type:

Float[Tensor, 'batch_size output_size']

Returns:

The output batch.