位置不共享卷积

Involution的一个特点:输入通道和输出通道必须是一样的,如果想实现输入和输出不一样,文末有方法。

实现1:

https://github.com/d-li14/involution/blob/21c3158fcbb4ecda8ed4626fcae8b01be511a598/cls/mmcls/models/utils/involution_naive.py

以来mmcv

mmcv安装:

pip install mmcv

import torch.nn as nn
from mmcv.cnn import ConvModule


class involution(nn.Module):

    def __init__(self,
                 channels,
                 kernel_size,
                 stride):
        super(involution, self).__init__()
        self.kernel_size = kernel_size
        self.stride = stride
        self.channels = channels
        reduction_ratio = 4
        self.group_channels = 16
        self.groups = self.channels // self.group_channels
        self.conv1 = Con

你可能感兴趣的:(深度学习宝典)