Positional Embedding
- class vformer.encoder.embedding.pos_embedding.PVTPosEmbedding(pos_shape, pos_dim, p_dropout=0.0, std=0.02)[source]
Positional Embedding class used in Pyramid vision transformer.
- 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.
- class vformer.encoder.embedding.pos_embedding.PosEmbedding(shape, dim, drop=None, sinusoidal=False, std=0.02)[source]
Generalised Positional Embedding class
- 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.