Single-Model Mixin#

Module for the single-model mixin class.

class SingleModelMixin[source]

Bases: object

Mixin that defines the forward pass and optimizer configuration for solvers backed by exactly one model. Provides properties to access the single model, optimizer, and scheduler.

Designed to be used in combination with any solver inheriting from BaseSolver.

forward(x)[source]

The forward pass implementation for the single model, which simply evaluates the model on the input.

Parameters:

x (torch.Tensor | LabelTensor | Data | Graph) – The input data.

Returns:

The output of the single model.

Return type:

torch.Tensor | LabelTensor | Data | Graph

configure_optimizers()[source]

Configure the optimizer and scheduler for the single model.

Returns:

The optimizer and the scheduler

Return type:

tuple[list[TorchOptimizer], list[TorchScheduler]]

property model

The single model used by the solver.

Returns:

The single model used by the solver.

Return type:

torch.nn.Module

property optimizer

The optimizer used by the solver.

Returns:

The optimizer used by the solver.

Return type:

TorchOptimizer

property scheduler

The scheduler used by the solver.

Returns:

The scheduler used by the solver.

Return type:

TorchScheduler