BaseTask#

class torchgeo.trainers.BaseTask[source]#

Bases: LightningModule, ABC

Abstract base class for all TorchGeo trainers.

Added in version 0.5.

ignore: Sequence[str] | str | None = 'weights'#

Parameters to ignore when saving hyperparameters.

model: Any#

Model to train.

monitor = 'val_loss'#

Performance metric to monitor in learning rate scheduler and callbacks.

mode = 'min'#

Whether the goal is to minimize or maximize the performance metric to monitor.

__init__()[source]#

Initialize a new BaseTask instance.

Parameters:

ignore – Arguments to skip when saving hyperparameters.

abstractmethod configure_models()[source]#

Initialize the model.

configure_losses()[source]#

Initialize the loss criterion.

configure_metrics()[source]#

Initialize the performance metrics.

configure_optimizers()[source]#

Initialize the optimizer and learning rate scheduler.

Returns:

Optimizer and learning rate scheduler.

Return type:

Optimizer | Sequence[Optimizer] | tuple[Sequence[Optimizer], Sequence[LRScheduler | ReduceLROnPlateau | LRSchedulerConfig]] | OptimizerConfig | OptimizerLRSchedulerConfig | Sequence[OptimizerConfig] | Sequence[OptimizerLRSchedulerConfig] | None

forward(*args, **kwargs)[source]#

Forward pass of the model.

Parameters:
  • args (Any) – Arguments to pass to model.

  • kwargs (Any) – Keyword arguments to pass to model.

Returns:

Output of the model.

Return type:

Any