Shortcuts

Note

You are reading the documentation for MMOCR 0.x, which will soon be deprecated by the end of 2022. We recommend you upgrade to MMOCR 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check out the maintenance plan, changelog, code and documentation of MMOCR 1.0 for more details.

Source code for mmocr.models.textrecog.encoders.channel_reduction_encoder

# Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn

from mmocr.models.builder import ENCODERS
from .base_encoder import BaseEncoder


[docs]@ENCODERS.register_module() class ChannelReductionEncoder(BaseEncoder): """Change the channel number with a one by one convoluational layer. Args: in_channels (int): Number of input channels. out_channels (int): Number of output channels. init_cfg (dict or list[dict], optional): Initialization configs. """ def __init__(self, in_channels, out_channels, init_cfg=dict(type='Xavier', layer='Conv2d')): super().__init__(init_cfg=init_cfg) self.layer = nn.Conv2d( in_channels, out_channels, kernel_size=1, stride=1, padding=0)
[docs] def forward(self, feat, img_metas=None): """ Args: feat (Tensor): Image features with the shape of :math:`(N, C_{in}, H, W)`. img_metas (None): Unused. Returns: Tensor: A tensor of shape :math:`(N, C_{out}, H, W)`. """ return self.layer(feat)
Read the Docs v: v0.6.3
Versions
latest
stable
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
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.