[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
深度可分离卷积主要分为两个过程,分别为逐通道卷积(Depthwise Convolution)和逐点卷积(Pointwise Convolution)。
* 逐通道卷积 Depthwise Convolution
Depthwise Convolution的一个卷积核负责一个通道,一个通道只被一个卷积核卷积,这个过程产生的feature
map通道数和输入的通道数完全一样。
卷积核的计算量为:3 x 3 x 3 = 27
* 逐点卷积 Pointwise Convolution
Pointwise Convolution的运算与常规卷积运算非常相似,它的卷积核的尺寸为
1×1×M,M为上一层的通道数。所以这里的卷积运算会将上一步的map在深度方向上进行加权组合,生成新的Feature
map。有几个卷积核就有几个输出Feature map。(卷积核的shape即为:1 x 1 x 输入通道数 x 输出通道数)
卷积核的计算量为 1 x 1 x 3 x 4 = 12
pytorch实现:xception中的深度可分离卷积
def fixed_padding(inputs, kernel_size, dilation): kernel_size_effective =
kernel_size + (kernel_size - 1) * (dilation - 1) pad_total =
kernel_size_effective - 1 pad_beg = pad_total // 2 pad_end = pad_total -
pad_beg padded_inputs = F.pad(inputs, (pad_beg, pad_end, pad_beg, pad_end))
return padded_inputs class SeparableConv2d(nn.Module): def __init__(self,
in_channels, out_channels, kernel_size=3, stride=1, dilation=1, bias=False,
BatchNorm=None): super(SeparableConv2d, self).__init__()
#逐通道卷积,groups代表通道分组数,对通道进行分组,普通卷积默认是1
#每个分组的输入通道是in_channels/groups,输出通道是groups/out_channels,需要整除。最后将每个分组的out_channels进行concat,得到最终的输出通道数
self.conv1 = nn.Conv2d(in_channels, in_channels, kernel_size, stride, 0,
dilation, groups=inplanes, bias=bias) self.bn = BatchNorm(inplanes)
self.pointwise = nn.Conv2d(in_channels, out_channels, 1, 1, 0, 1, 1, bias=bias)
def forward(self, x): x = fixed_padding(x, self.conv1.kernel_size[0],
dilation=self.conv1.dilation[0]) x = self.conv1(x) x = self.bn(x) x =
self.pointwise(x) return x