- class mmcv.cnn.ContextBlock(in_channels: int, ratio: float, pooling_type: str = 'att', fusion_types: tuple = ('channel_add'))¶
ContextBlock module in GCNet.
See ‘GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond’ (https://arxiv.org/abs/1904.11492) for details.
in_channels (int) – Channels of the input feature map.
ratio (float) – Ratio of channels of transform bottleneck
pooling_type (str) – Pooling method for context modeling. Options are ‘att’ and ‘avg’, stand for attention pooling and average pooling respectively. Default: ‘att’.
fusion_types (Sequence[str]) – Fusion method for feature fusion, Options are ‘channels_add’, ‘channel_mul’, stand for channelwise addition and multiplication respectively. Default: (‘channel_add’,)
- forward(x: torch.Tensor) → torch.Tensor¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.