Extra Model Structures#
terratorch.models.model.Model
#
Bases: ABC
, Module
Source code in terratorch/models/model.py
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 |
required |
Source code in terratorch/models/model.py
terratorch.models.model.ModelOutput
dataclass
#
terratorch.registry.registry.MultiSourceRegistry
#
Bases: Mapping[str, T]
, Generic[T]
Registry that searches in multiple sources
Correct functioning of this class depends on registries raising a KeyError when the model is not found.
Source code in terratorch/registry/registry.py
register_source(prefix, registry)
#
Register a source in the registry
terratorch.registry.registry.Registry
#
Bases: Set
Registry holding model constructors and multiple additional sources.
This registry behaves as a set of strings, which are model names, to model classes or functions which instantiate model classes.
In addition, it can instantiate models with the build method.
Add constructors to the registry by annotating them with @registry.register.
>>> registry = Registry()
>>> @registry.register
... def model(*args, **kwargs):
... return object()
>>> "model" in registry
True
>>> model_instance = registry.build("model")
Source code in terratorch/registry/registry.py
build(name, *constructor_args, **constructor_kwargs)
#
Build and return the component. Use prefixes ending with _ to forward to a specific source
Source code in terratorch/registry/registry.py
register(constructor)
#
Register a component in the registry. Used as a decorator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
constructor
|
Callable | type
|
Function or class to be decorated with @register. |
required |