pymor.algorithms.ml.nn.neural_networks¶
Module Contents¶
- class pymor.algorithms.ml.nn.neural_networks.FullyConnectedNN(hidden_layers, input_dimension=None, output_dimension=None, activation_function=torch.tanh)[source]¶
Bases:
torch.nn.Module,pymor.core.base.BasicObjectClass for neural networks with fully connected layers.
This class implements neural networks consisting of linear and fully connected layers. Furthermore, the same activation function is used between each layer, except for the last one where no activation function is applied.
- Parameters:
hidden_layers – List of sizes (i.e. number of neurons) for the hidden layers of the neural network.
input_dimension – Input dimension of the neural network.
output_dimension – Output dimension of the neural network.
activation_function – Function to use as activation function between the single layers.
Methods
Performs the forward pass through the neural network.
Set new values for input and output dimension of the neural network.
- forward(x)[source]¶
Performs the forward pass through the neural network.
Applies the weights in the linear layers and passes the outcomes to the activation function.
- Parameters:
x – Input for the neural network.
- Returns:
The output of the neural network for the input
x.
- set_input_output_dimensions(input_dimension, output_dimension)[source]¶
Set new values for input and output dimension of the neural network.
Initializes a new neural network with the updated input and output dimensions.
- Parameters:
input_dimension – Input dimension of the neural network.
output_dimension – Output dimension of the neural network.