Single Model Solver#
Module for the single-model solver class.
- class SingleModelSolver(problem, model, optimizer=None, scheduler=None, weighting=None, loss=None, use_lt=True)[source]
Bases:
SingleModelMixin,ConditionAggregatorMixin,BaseSolverBase class for implementing single-model solvers.
This class provides the standard starting point for solvers based on a single model. It combines the shared solver machinery from
BaseSolverwith single-model handling and condition-wise loss aggregation.Subclasses can inherit from this class to implement solver-specific behavior while reusing the common logic for model registration, optimizer and scheduler setup, loss evaluation, weighting, and aggregation across problem conditions.
Initialization of the
SingleModelSolverclass.- 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.