Skip to content

Multi-Layer Perceptron (MLP)

torchmil.nn.MLP

Bases: Module

Multi-Layer Perceptron (MLP) class.

__init__(input_size=512, linear_sizes=[100, 50], activations=['relu', 'relu'])

Parameters:

  • input_size (int, default: 512 ) –

    Size of the input features.

  • linear_sizes (list of int, default: [100, 50] ) –

    List containing the sizes of each linear layer.

  • activations (list of str, default: ['relu', 'relu'] ) –

    List containing the activation functions for each layer.

forward(X)

Forward pass through the MLP.

Parameters:

  • X (Tensor) –

    Output tensor of shape (batch_size, ...)

Returns:

torch.Tensor: Output of the MLP with shape `(batch_size, linear_sizes[-1])`