geowatch.tasks.fusion.architectures.segmenter_decoder module¶
Adapted from https://github.com/rst
- geowatch.tasks.fusion.architectures.segmenter_decoder.trunc_normal_(tensor: Tensor, mean: float = 0.0, std: float = 1.0, a: float = -2.0, b: float = 2.0) Tensor [source]¶
Fills the input Tensor with values drawn from a truncated normal distribution. The values are effectively drawn from the normal distribution \(\mathcal{N}(\text{mean}, \text{std}^2)\) with values outside \([a, b]\) redrawn until they are within the bounds. The method used for generating the random values works best when \(a \leq \text{mean} \leq b\). :Parameters: * tensor – an n-dimensional torch.Tensor
mean – the mean of the normal distribution
std – the standard deviation of the normal distribution
a – the minimum cutoff value
b – the maximum cutoff value
Examples
>>> w = torch.empty(3, 5) >>> nn.init.trunc_normal_(w)
- geowatch.tasks.fusion.architectures.segmenter_decoder.drop_path(x, drop_prob: float = 0.0, training: bool = False)[source]¶
Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
This is the same as the DropConnect impl I created for EfficientNet, etc networks, however, the original name is misleading as ‘Drop Connect’ is a different form of dropout in a separate paper… See discussion: https://github.com/tensorflow/tpu/issues/494#issuecomment-532968956 … I’ve opted for changing the layer and argument names to ‘drop path’ rather than mix DropConnect as a layer name and use ‘survival rate’ as the argument.
- class geowatch.tasks.fusion.architectures.segmenter_decoder.DropPath(drop_prob=None)[source]¶
Bases:
Module
Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
- class geowatch.tasks.fusion.architectures.segmenter_decoder.FeedForward(dim, hidden_dim, dropout, out_dim=None)[source]¶
Bases:
Module
- property unwrapped¶
- class geowatch.tasks.fusion.architectures.segmenter_decoder.Attention(dim, heads, dropout)[source]¶
Bases:
Module
- property unwrapped¶
- class geowatch.tasks.fusion.architectures.segmenter_decoder.Block(dim, heads, mlp_dim, dropout, drop_path)[source]¶
Bases:
Module
- class geowatch.tasks.fusion.architectures.segmenter_decoder.DecoderLinear(n_cls, patch_size, d_encoder)[source]¶
Bases:
Module
- class geowatch.tasks.fusion.architectures.segmenter_decoder.MaskTransformerDecoder(n_cls, d_model=192, n_layers=2, d_encoder='auto', n_heads='auto', d_ff='auto', drop_path_rate=0.0, dropout=0.1)[source]¶
Bases:
Module
This was originally the MaskTransformer and is being modified for the arbitrary output size design.
Example
>>> from geowatch.tasks.fusion.architectures.segmenter_decoder import * # NOQA >>> self = MaskTransformerDecoder(8, n_layers=8) >>> # Batch size, number of tokens, and token dimension size >>> B, N, D = 1, 10, self.d_model >>> x = torch.rand(B, N, D) >>> y = self.forward(x) >>> assert y.shape[0:2] == x.shape[0:2], 'only in case where x is token size' >>> assert y.shape[2] == self.n_cls, 'should always be true'