Shortcuts

SATRNEncoderLayer

class mmocr.models.textrecog.SATRNEncoderLayer(d_model=512, d_inner=512, n_head=8, d_k=64, d_v=64, dropout=0.1, qkv_bias=False, init_cfg=None)[source]

Implement encoder layer for SATRN, see `SATRN.

<https://arxiv.org/abs/1910.04396>`_.

Parameters
  • d_model (int) – Dimension \(D_m\) of the input from previous model. Defaults to 512.

  • d_inner (int) – Hidden dimension of feedforward layers. Defaults to 256.

  • n_head (int) – Number of parallel attention heads. Defaults to 8.

  • d_k (int) – Dimension of the key vector. Defaults to 64.

  • d_v (int) – Dimension of the value vector. Defaults to 64.

  • dropout (float) – Dropout rate. Defaults to 0.1.

  • qkv_bias (bool) – Whether to use bias. Defaults to False.

  • init_cfg (dict or list[dict], optional) – Initialization configs. Defaults to None.

Return type

None

forward(x, h, w, mask=None)[source]

Forward propagation of encoder.

Parameters
  • x (Tensor) – Feature tensor of shape \((N, h*w, D_m)\).

  • h (int) – Height of the original feature.

  • w (int) – Width of the original feature.

  • mask (Tensor, optional) – Mask used for masked multi-head attention. Defaults to None.

Returns

A tensor of shape \((N, h*w, D_m)\).

Return type

Tensor

Read the Docs v: latest
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.