Skip to content

Extra model structures

terratorch.models.model.Model #

Bases: ABC, Module

Source code in terratorch/models/model.py
class Model(ABC, nn.Module):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
    @abstractmethod
    def freeze_encoder(self):
        pass

    @abstractmethod
    def freeze_decoder(self):
        pass

    @abstractmethod
    def forward(self, *args, **kwargs) -> ModelOutput:
        pass

terratorch.models.model.AuxiliaryHead dataclass #

Class containing all information to create auxiliary heads.

Parameters:

Name Type Description Default
name str

Name of the head. Should match the name given to the auxiliary loss.

required
decoder str

Name of the decoder class to be used.

required
decoder_args dict | None

parameters to be passed to the decoder constructor. Parameters for the decoder should be prefixed with decoder_. Parameters for the head should be prefixed with head_.

required
Source code in terratorch/models/model.py
@dataclass
class AuxiliaryHead:
    """Class containing all information to create auxiliary heads.

    Args:
        name (str): Name of the head. Should match the name given to the auxiliary loss.
        decoder (str): Name of the decoder class to be used.
        decoder_args (dict | None): parameters to be passed to the decoder constructor.
            Parameters for the decoder should be prefixed with `decoder_`.
            Parameters for the head should be prefixed with `head_`.
    """

    name: str
    decoder: str
    decoder_args: dict | None

terratorch.models.model.ModelOutput dataclass #

Source code in terratorch/models/model.py
@dataclass
class ModelOutput:
    output: Tensor
    auxiliary_heads: dict[str, Tensor] = None

Last update: March 20, 2025