DOFA#

class torchgeo.models.DOFA(img_size=224, patch_size=16, drop_rate=0.0, embed_dim=1024, depth=24, num_heads=16, dynamic_embed_dim=128, num_classes=45, global_pool=True, mlp_ratio=4.0, norm_layer=functools.partial(<class 'torch.nn.modules.normalization.LayerNorm'>, eps=1e-06))[source]#

Bases: Module

Dynamic One-For-All (DOFA) model.

Reference implementation:

If you use this model in your research, please cite the following paper:

Added in version 0.6.

__init__(img_size=224, patch_size=16, drop_rate=0.0, embed_dim=1024, depth=24, num_heads=16, dynamic_embed_dim=128, num_classes=45, global_pool=True, mlp_ratio=4.0, norm_layer=functools.partial(<class 'torch.nn.modules.normalization.LayerNorm'>, eps=1e-06))[source]#

Initialize a new DOFA instance.

Parameters:
  • img_size (int) – Input image size.

  • patch_size (int) – Patch size.

  • drop_rate (float) – Head dropout rate.

  • embed_dim (int) – Transformer embedding dimension.

  • depth (int) – Depth of transformer.

  • num_heads (int) – Number of attention heads.

  • dynamic_embed_dim (int) – Dimensions of dynamic weight generator.

  • num_classes (int) – Number of classes for classification head.

  • global_pool (bool) – Whether or not to perform global pooling.

  • mlp_ratio (float) – Ratio of MLP hidden dim to embedding dim.

  • norm_layer (type[Module]) – Normalization layer.

forward_features(x, wavelengths)[source]#

Forward pass of the feature embedding layer.

Parameters:
  • x (Tensor) – Input mini-batch.

  • wavelengths (list[float]) – Wavelengths of each spectral band (μm).

Returns:

Output mini-batch.

Return type:

Tensor

forward_head(x, pre_logits=False)[source]#

Forward pass of the attention head.

Parameters:
  • x (Tensor) – Input mini-batch.

  • pre_logits (bool) – Whether or not to return the layer before logits are computed.

Returns:

Output mini-batch.

Return type:

Tensor

forward(x, wavelengths)[source]#

Forward pass of the model.

Parameters:
  • x (Tensor) – Input mini-batch.

  • wavelengths (list[float]) – Wavelengths of each spectral band (μm).

Returns:

Output mini-batch.

Return type:

Tensor

torchgeo.models.dofa_small_patch16_224(*args, **kwargs)[source]#

Dynamic One-For-All (DOFA) small patch size 16 model.

If you use this model in your research, please cite the following paper:

Added in version 0.6.

Parameters:
  • *args (Any) – Additional arguments to pass to DOFA.

  • **kwargs (Any) – Additional keyword arguments to pass to DOFA.

Returns:

A DOFA small 16 model.

Return type:

DOFA

torchgeo.models.dofa_base_patch16_224(weights=None, *args, **kwargs)[source]#

Dynamic One-For-All (DOFA) base patch size 16 model.

If you use this model in your research, please cite the following paper:

Added in version 0.6.

Parameters:
  • weights (DOFABase16_Weights | None) – Pre-trained model weights to use.

  • *args (Any) – Additional arguments to pass to DOFA.

  • **kwargs (Any) – Additional keyword arguments to pass to DOFA.

Returns:

A DOFA base 16 model.

Return type:

DOFA

torchgeo.models.dofa_large_patch16_224(weights=None, *args, **kwargs)[source]#

Dynamic One-For-All (DOFA) large patch size 16 model.

If you use this model in your research, please cite the following paper:

Added in version 0.6.

Parameters:
  • weights (DOFALarge16_Weights | None) – Pre-trained model weights to use.

  • *args (Any) – Additional arguments to pass to DOFA.

  • **kwargs (Any) – Additional keyword arguments to pass to DOFA.

Returns:

A DOFA large 16 model.

Return type:

DOFA

torchgeo.models.dofa_huge_patch14_224(*args, **kwargs)[source]#

Dynamic One-For-All (DOFA) huge patch size 14 model.

If you use this model in your research, please cite the following paper:

Added in version 0.6.

Parameters:
  • *args (Any) – Additional arguments to pass to DOFA.

  • **kwargs (Any) – Additional keyword arguments to pass to DOFA.

Returns:

A DOFA huge 14 model.

Return type:

DOFA

class torchgeo.models.DOFABase16_Weights(*values)[source]#

Bases: WeightsEnum

Dynamic One-For-All (DOFA) base patch size 16 weights.

Added in version 0.6.

__new__(value)#
class torchgeo.models.DOFALarge16_Weights(*values)[source]#

Bases: WeightsEnum

Dynamic One-For-All (DOFA) large patch size 16 weights.

Added in version 0.6.

__new__(value)#