Shortcuts

备注

您正在阅读 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.

Common Components

InvertedResidual

Inverted Residual Block.

SELayer

Squeeze-and-Excitation Module.

ShiftWindowMSA

Shift Window Multihead Self-Attention Module.

MultiheadAttention

Multi-head Attention Module.

ConditionalPositionEncoding

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

返回类型

int

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)

is_tracing

mmcls.models.utils.is_tracing() bool[源代码]

Determine whether the model is called during the tracing of code with torch.jit.trace.

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

Free document hosting provided by Read the Docs.