TemporalRegressionTask#

class torchgeo.trainers.TemporalRegressionTask(model='ltae', in_channels=1, num_outputs=1, labels=None, out_steps=1, loss='mse', lr=0.001, patience=10, **kwargs)[source]#

Bases: RegressionMixin, BaseTask

Trainer for sequence-to-sequence temporal regression.

Added in version 0.10.

__init__(model='ltae', in_channels=1, num_outputs=1, labels=None, out_steps=1, loss='mse', lr=0.001, patience=10, **kwargs)[source]#

Initialize a new TemporalRegressionTask instance.

Parameters:
  • model (Literal['ltae']) – Name of the model architecture.

  • in_channels (int) – Number of input features per time step (the C dimension of the (B, T, C) input tensor).

  • num_outputs (int) – Number of output features per time step (the C dimension of the (B, T, C) target tensor).

  • labels (list[str] | None) – List of feature names.

  • out_steps (int) – Number of output time steps (the T dimension of the (B, T, C) target tensor).

  • loss (Literal['mae', 'mse']) – Loss function.

  • lr (float) – Learning rate for optimizer.

  • patience (int) – Patience for learning rate scheduler.

  • **kwargs (Any) – Additional keyword arguments passed to the model constructor.

Added in version 0.10.

configure_models()[source]#

Initialize the model.

training_step(batch, batch_idx, dataloader_idx=0)[source]#

Compute the training loss and additional metrics.

Parameters:
  • batch (dict[str, Any]) – The output of the DataLoader.

  • batch_idx (int) – Integer displaying index of this batch.

  • dataloader_idx (int) – Index of the current dataloader.

Returns:

The loss tensor.

Return type:

Tensor

validation_step(batch, batch_idx, dataloader_idx=0)[source]#

Compute the validation loss and additional metrics.

Parameters:
  • batch (dict[str, Any]) – The output of the DataLoader.

  • batch_idx (int) – Integer displaying index of this batch.

  • dataloader_idx (int) – Index of the current dataloader.

test_step(batch, batch_idx, dataloader_idx=0)[source]#

Compute the test loss and additional metrics.

Parameters:
  • batch (dict[str, Any]) – The output of the DataLoader.

  • batch_idx (int) – Integer displaying index of this batch.

  • dataloader_idx (int) – Index of the current dataloader.

predict_step(batch, batch_idx, dataloader_idx=0)[source]#

Compute predicted values.

Parameters:
  • batch (dict[str, Any]) – The output of the DataLoader.

  • batch_idx (int) – Integer displaying index of this batch.

  • dataloader_idx (int) – Index of the current dataloader.

Returns:

Predicted values of shape (B, T, C).

Return type:

Tensor