pymor.algorithms.ml.nn.regressor

Module Contents

class pymor.algorithms.ml.nn.regressor.NeuralNetworkRegressor(neural_network=FullyConnectedNN([30, 30, 30]), validation_ratio=0.1, tol=None, **kwargs)[source]

Bases: pymor.core.base.BasicObject

Scikit-learn-style regressor using neural networks from PyTorch.

Parameters:
  • neural_network – Neural network to use in the regressor. The neural network should implement a function set_input_output_dimensions that allows to change the input and the output dimension also after initialization.

  • validation_ratio – Ratio of training data to use for validation during training.

  • tol – Prescribed tolerance for the neural network training. If None, the neural network with the smallest validation loss is used (usually, multiple restarts of the training using different initial guesses for the weights and biases are performed).

  • kwargs – Additional training parameters passed to the training algorithm. For training, multiple_restarts_training is used. The default training parameters will be overriden by the additional training parameters provided here.

Methods

fit

Fit neural network using PyTorch optimization algorithms.

predict

Predict the target for the input X.

fit(X, Y, **kwargs)[source]

Fit neural network using PyTorch optimization algorithms.

Parameters:
  • X – Training inputs.

  • Y – Training targets.

  • kwargs – Additional training parameters that can replace the parameters passed to the constructor.

Returns:

The trained regressor.

predict(X)[source]

Predict the target for the input X.

Parameters:

X – Input for which to compute the prediction.

Returns:

Prediction obtained by the neural network.