备注
您正在阅读 MMClassification 0.x 版本的文档。MMClassification 0.x 会在 2022 年末被切换为次要分支。建议您升级到 MMClassification 1.0 版本,体验更多新特性和新功能。请查阅 MMClassification 1.0 的安装教程、迁移教程以及更新日志。
mmcls.models.utils.ShiftWindowMSA¶
- class mmcls.models.utils.ShiftWindowMSA(embed_dims, num_heads, window_size, shift_size=0, qkv_bias=True, qk_scale=None, attn_drop=0, proj_drop=0, dropout_layer={'drop_prob': 0.0, 'type': 'DropPath'}, pad_small_map=False, input_resolution=None, auto_pad=None, window_msa=<class 'mmcls.models.utils.attention.WindowMSA'>, msa_cfg={}, init_cfg=None)[源代码]¶
Shift Window Multihead Self-Attention Module.
- 参数
embed_dims (int) – Number of input channels.
num_heads (int) – Number of attention heads.
window_size (int) – The height and width of the window.
shift_size (int, optional) – The shift step of each window towards right-bottom. If zero, act as regular window-msa. Defaults to 0.
qkv_bias (bool, optional) – If True, add a learnable bias to q, k, v. Defaults to True
qk_scale (float | None, optional) – Override default qk scale of head_dim ** -0.5 if set. Defaults to None.
attn_drop (float, optional) – Dropout ratio of attention weight. Defaults to 0.0.
proj_drop (float, optional) – Dropout ratio of output. Defaults to 0.
dropout_layer (dict, optional) – The dropout_layer used before output. Defaults to dict(type=’DropPath’, drop_prob=0.).
pad_small_map (bool) – If True, pad the small feature map to the window size, which is common used in detection and segmentation. If False, avoid shifting window and shrink the window size to the size of feature map, which is common used in classification. Defaults to False.
version (str, optional) – Version of implementation of Swin Transformers. Defaults to v1.
init_cfg (dict, optional) – The extra config for initialization. Defaults to None.