FeedForward#
- class FeedForward(input_dimensions, output_dimensions, inner_size=20, n_layers=2, func=<class 'torch.nn.modules.activation.Tanh'>, layers=None, bias=True)[source]#
Bases:
Module
The PINA implementation of feedforward network, also refered as multilayer perceptron.
- Parameters:
input_dimensions (int) – The number of input components of the model. Expected tensor shape of the form \((*, d)\), where * means any number of dimensions including none, and \(d\) the
input_dimensions
.output_dimensions (int) – The number of output components of the model. Expected tensor shape of the form \((*, d)\), where * means any number of dimensions including none, and \(d\) the
output_dimensions
.inner_size (int) – number of neurons in the hidden layer(s). Default is 20.
n_layers (int) – number of hidden layers. Default is 2.
func (torch.nn.Module) – the activation function to use. If a single
torch.nn.Module
is passed, this is used as activation function after any layers, except the last one. If a list of Modules is passed, they are used as activation functions at any layers, in order.layers (list(int) | tuple(int)) – a list containing the number of neurons for any hidden layers. If specified, the parameters
n_layers
einner_size
are not considered.bias (bool) – If
True
the MLP will consider some bias.
- forward(x)[source]#
Defines the computation performed at every call.
- Parameters:
x (torch.Tensor) – The tensor to apply the forward pass.
- Returns:
the output computed by the model.
- Return type: