Positional
- class vformer.encoder.embedding.pos_embedding.PVTPosEmbedding(pos_shape, pos_dim, p_dropout=0.0, std=0.02)[source]
- Parameters
pos_shape (int or tuple(int)) – The shape of the absolute position embedding.
pos_dim (int) – The dimension of the absolute position embedding.
p_dropout (float, optional) – Probability of an element to be zeroed, default is 0.2
std (float) – Standard deviation for truncated normal distribution
- forward(x, H, W, mode='bilinear')[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- resize_pos_embed(pos_embed, shape, mode='bilinear', **kwargs)[source]
- Parameters
pos_embed (torch.Tensor) – Position embedding weights
shape (tuple) – Required shape
mode (str ('nearest' | 'linear' | 'bilinear' | 'bicubic' | 'trilinear')) – Algorithm used for up/down sampling, default is ‘bilinear’
- class vformer.encoder.embedding.pos_embedding.PosEmbedding(shape, dim, drop=None, sinusoidal=False, std=0.02)[source]
- forward(x)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.