Shortcuts

SAREncoder

class mmocr.models.textrecog.SAREncoder(enc_bi_rnn=False, rnn_dropout=0.0, enc_gru=False, d_model=512, d_enc=512, mask=True, init_cfg=[{'type': 'Xavier', 'layer': 'Conv2d'}, {'type': 'Uniform', 'layer': 'BatchNorm2d'}], **kwargs)[源代码]

Implementation of encoder module in `SAR.

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

参数
  • enc_bi_rnn (bool) – If True, use bidirectional RNN in encoder. Defaults to False.

  • rnn_dropout (float) – Dropout probability of RNN layer in encoder. Defaults to 0.0.

  • enc_gru (bool) – If True, use GRU, else LSTM in encoder. Defaults to False.

  • d_model (int) – Dim \(D_i\) of channels from backbone. Defaults to 512.

  • d_enc (int) – Dim \(D_m\) of encoder RNN layer. Defaults to 512.

  • mask (bool) – If True, mask padding in RNN sequence. Defaults to True.

  • init_cfg (dict or list[dict], optional) – Initialization configs. Defaults to [dict(type=’Xavier’, layer=’Conv2d’), dict(type=’Uniform’, layer=’BatchNorm2d’)].

返回类型

None

forward(feat, data_samples=None)[源代码]
参数
  • feat (Tensor) – Tensor of shape \((N, D_i, H, W)\).

  • data_samples (list[TextRecogDataSample], optional) – Batch of TextRecogDataSample, containing valid_ratio information. Defaults to None.

返回

A tensor of shape \((N, D_m)\).

返回类型

Tensor

Read the Docs v: stable
Versions
latest
stable
0.x
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.