DeepEnsemblePINN#

class DeepEnsemblePINN(problem, models, loss=None, optimizers=None, schedulers=None, weighting=None, ensemble_dim=0)[source]#

Bases: PINNInterface, DeepEnsembleSolverInterface

Deep Ensemble Physics Informed Solver class. This class implements a Deep Ensemble for Physics Informed Neural Networks using user specified model``s to solve a specific ``problem.

An ensemble model is constructed by combining multiple models that solve the same type of problem. Mathematically, this creates an implicit distribution \(p(\mathbf{u} \mid \mathbf{s})\) over the possible outputs \(\mathbf{u}\), given the original input \(\mathbf{s}\). The models \(\mathcal{M}_{i\in (1,\dots,r)}\) in the ensemble work collaboratively to capture different aspects of the data or task, with each model contributing a distinct prediction \(\mathbf{y}_{i}=\mathcal{M}_i(\mathbf{u} \mid \mathbf{s})\). By aggregating these predictions, the ensemble model can achieve greater robustness and accuracy compared to individual models, leveraging the diversity of the models to reduce overfitting and improve generalization. Furthemore, statistical metrics can be computed, e.g. the ensemble mean and variance:

\[\mathbf{\mu} = \frac{1}{N}\sum_{i=1}^r \mathbf{y}_{i}\]
\[\mathbf{\sigma^2} = \frac{1}{N}\sum_{i=1}^r (\mathbf{y}_{i} - \mathbf{\mu})^2\]

During training the PINN loss is minimized by each ensemble model:

\[\mathcal{L}_{\rm{problem}} = \frac{1}{N}\sum_{i=1}^4 \mathcal{L}(\mathcal{A}[\mathbf{u}](\mathbf{x}_i)) + \frac{1}{N}\sum_{i=1}^N \mathcal{L}(\mathcal{B}[\mathbf{u}](\mathbf{x}_i)),\]

for the differential system:

\[\begin{split}\begin{cases} \mathcal{A}[\mathbf{u}](\mathbf{x})=0\quad,\mathbf{x}\in\Omega\\ \mathcal{B}[\mathbf{u}](\mathbf{x})=0\quad, \mathbf{x}\in\partial\Omega \end{cases}\end{split}\]

\(\mathcal{L}\) indicates a specific loss function, typically the MSE:

\[\mathcal{L}(v) = \| v \|^2_2.\]

See also

Original reference: Zou, Z., Wang, Z., & Karniadakis, G. E. (2025). Learning and discovering multiple solutions using physics-informed neural networks with random initialization and deep ensemble. DOI: arXiv:2503.06320.

Warning

This solver does not work with inverse problem. Hence in the problem definition must not inherit from InverseProblem.

Initialization of the DeepEnsemblePINN class.

Parameters:
Raises:

NotImplementedError – If an inverse problem is passed.

loss_data(input, target)[source]#

Compute the data loss for the ensemble PINN solver by evaluating the loss between the network’s output and the true solution for each model. This method should not be overridden, if not intentionally.

Parameters:
Returns:

The supervised loss, averaged over the number of observations.

Return type:

torch.Tensor

loss_phys(samples, equation)[source]#

Computes the physics loss for the ensemble PINN solver by evaluating the loss between the network’s output and the true solution for each model. This method should not be overridden, if not intentionally.

Parameters:
Returns:

The computed physics loss.

Return type:

LabelTensor