SupervisedSolverInterface#

class SupervisedSolverInterface(loss=None, **kwargs)[source]#

Bases: SolverInterface

Base class for Supervised solvers. This class implements a Supervised Solver , using a user specified model to solve a specific problem.

The SupervisedSolverInterface class can be used to define Supervised solvers that work with one or multiple optimizers and/or models. By default, it is compatible with problems defined by AbstractProblem, and users can choose the problem type the solver is meant to address.

Initialization of the SupervisedSolver class.

Parameters:
accepted_conditions_types#

alias of InputTargetCondition

optimization_cycle(batch)[source]#

The optimization cycle for the solvers.

Parameters:

batch (list[tuple[str, dict]]) – A batch of data. Each element is a tuple containing a condition name and a dictionary of points.

Returns:

The losses computed for all conditions in the batch, casted to a subclass of torch.Tensor. It should return a dict containing the condition name and the associated scalar loss.

Return type:

dict

abstract loss_data(input, target)[source]#

Compute the data loss for the Supervised. This method is abstract and should be override by derived classes.

Parameters:
Returns:

The supervised loss, averaged over the number of observations.

Return type:

LabelTensor | torch.Tensor | Graph | Data

property loss#

The loss function to be minimized.

Returns:

The loss function to be minimized.

Return type:

torch.nn.Module