Remark on the documentation:

Due to an issue in autoapi, the classes NeuralNetworkStatefreeOutputModel, NeuralNetworkInstationaryModel, NeuralNetworkInstationaryStatefreeOutputModel and FullyConnectedNN do not appear in the documentation, see

Module Contents



Class for models of stationary problems that use artificial neural networks.

class pymor.models.neural_network.NeuralNetworkModel(neural_network, parameters={}, output_functional=None, products=None, error_estimator=None, visualizer=None, name=None)[source]

Bases: pymor.models.interface.Model

Class for models of stationary problems that use artificial neural networks.

This class implements a Model that uses a neural network for solving.



The neural network that approximates the mapping from parameter space to solution space. Should be an instance of FullyConnectedNN with input size that matches the (total) number of parameters and output size equal to the dimension of the reduced space.


Parameters of the reduced order model (the same as used in the full-order model).


Operator mapping a given solution to the model output. In many applications, this will be a Functional, i.e. an Operator mapping to scalars. This is not required, however.


A dict of inner product Operators defined on the discrete space the problem is posed on. For each product with key 'x' a corresponding attribute x_product, as well as a norm method x_norm is added to the model.


An error estimator for the problem. This can be any object with an estimate_error(U, mu, m) method. If error_estimator is not None, an estimate_error(U, mu) method is added to the model which will call error_estimator.estimate_error(U, mu, self).


A visualizer for the problem. This can be any object with a visualize(U, m, ...) method. If visualizer is not None, a visualize(U, *args, **kwargs) method is added to the model which forwards its arguments to the visualizer’s visualize method.


Name of the model.

_compute_solution(self, mu=None, **kwargs)[source]

Compute the model’s solution for parameter values mu.

This method is called by the default implementation of compute in pymor.models.interface.Model.



Parameter values for which to compute the solution.


Additional keyword arguments to customize how the solution is computed or to select additional data to be returned.


VectorArray with the computed solution or a dict which at least must contain the key 'solution'.