备注
您正在阅读 MMClassification 0.x 版本的文档。MMClassification 0.x 会在 2022 年末被切换为次要分支。建议您升级到 MMClassification 1.0 版本,体验更多新特性和新功能。请查阅 MMClassification 1.0 的安装教程、迁移教程以及更新日志。
mmcls.models.utils¶
This package includes some helper functions and common components used in various networks.
mmcls.models.utils
Common Components¶
Inverted Residual Block. |
|
Squeeze-and-Excitation Module. |
|
Shift Window Multihead Self-Attention Module. |
|
Multi-head Attention Module. |
|
The Conditional Position Encoding (CPE) module. |
Helper Functions¶
channel_shuffle¶
- mmcls.models.utils.channel_shuffle(x, groups)[源代码]¶
Channel Shuffle operation.
This function enables cross-group information flow for multiple groups convolution layers.
- 参数
x (Tensor) – The input tensor.
groups (int) – The number of groups to divide the input tensor in the channel dimension.
- 返回
The output tensor after channel shuffle operation.
- 返回类型
Tensor
make_divisible¶
- mmcls.models.utils.make_divisible(value, divisor, min_value=None, min_ratio=0.9)[源代码]¶
Make divisible function.
This function rounds the channel number down to the nearest value that can be divisible by the divisor.
- 参数
value (int) – The original channel number.
divisor (int) – The divisor to fully divide the channel number.
min_value (int, optional) – The minimum value of the output channel. Default: None, means that the minimum value equal to the divisor.
min_ratio (float) – The minimum ratio of the rounded channel number to the original channel number. Default: 0.9.
- 返回
The modified output channel number
- 返回类型
to_ntuple¶
- mmcls.models.utils.to_ntuple(n)¶
A to_tuple function generator.
It returns a function, this function will repeat the input to a tuple of length
n
if the input is not an Iterable object, otherwise, return the input directly.- 参数
n (int) – The number of the target length.
- mmcls.models.utils.to_2tuple(x)¶
- mmcls.models.utils.to_3tuple(x)¶
- mmcls.models.utils.to_4tuple(x)¶