Supervised Single Model Solver#

Module for the supervised single-model solver class.

class SupervisedSingleModelSolver(problem, model, optimizer=None, scheduler=None, weighting=None, loss=None, use_lt=True)[source]

Bases: SingleModelSolver

Single-model solver for supervised learning problems.

This solver is designed for problems defined by input-target pairs and uses a single model to approximate the mapping from input variables to target variables. It supports only InputTargetCondition conditions.

Given a model \(\mathcal{M}\), the solver minimizes the discrepancy between the target values \(\mathbf{u}_i\) and the model predictions \(\mathcal{M}(\mathbf{s}_i)\) evaluated at the input data \(\mathbf{s}_i\).

The supervised loss minimized during training is

\[\mathcal{L}_{\mathrm{problem}} = \frac{1}{N} \sum_{i=1}^{N} \mathcal{L} \left( \mathbf{u}_i - \mathcal{M}(\mathbf{s}_i) \right),\]

where \(\mathcal{L}\) is the selected loss function, typically the mean squared error.

Initialization of the SupervisedSingleModelSolver class.

Parameters:
  • problem (BaseProblem) – The problem to be solved.

  • model (torch.nn.Module) – The model used by the solver.

  • optimizer (TorchOptimizer) – The optimizer used by the solver. If None, the torch.optim.Adam optimizer with a learning rate of 0.001 is used. Default is None.

  • scheduler (TorchScheduler) – The scheduler used by the solver. If None, the torch.optim.lr_scheduler.ConstantLR scheduler with a factor of 1.0 is used. Default is None.

  • weighting (BaseWeighting) – The weighting strategy used to combine condition losses. If None, no weighting is applied. Default is None.

  • loss – The loss function used to compute residual losses. If None, torch.nn.MSELoss is used. Default is None.

  • use_lt (bool) – If True, the solver uses LabelTensors as input. Default is True.