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:
SingleModelSolverSingle-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
InputTargetConditionconditions.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
SupervisedSingleModelSolverclass.- 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, thetorch.optim.Adamoptimizer with a learning rate of0.001is used. Default isNone.scheduler (TorchScheduler) – The scheduler used by the solver. If
None, thetorch.optim.lr_scheduler.ConstantLRscheduler with a factor of1.0is used. Default isNone.weighting (BaseWeighting) – The weighting strategy used to combine condition losses. If
None, no weighting is applied. Default isNone.loss – The loss function used to compute residual losses. If
None,torch.nn.MSELossis used. Default isNone.use_lt (bool) – If
True, the solver uses LabelTensors as input. Default isTrue.