卷积和池化大小变化
(图像尺寸-卷积核尺寸 + 2*填充值)/步长+1
(图像尺寸-池化窗尺寸 + 2*填充值)/步长+1
卷积核计算公式
SeNet源码
self.se = nn.Sequential(
nn.AdaptiveAvgPool2d((1,1)),
nn.Conv2d(filter3,filter3//16,kernel_size=1),
nn.ReLU(),
nn.Conv2d(filter3//16,filter3,kernel_size=1),
nn.Sigmoid()
)
SimAM
class Simam_module(torch.nn.Module):
def __init__(self, channels=None, e_lambda=1e-4):
super(Simam_module, self).__init__()
self.activaton = nn.Sigmoid()
self.e_lambda = e_lambda
def __repr__(self):
s = self.__class__.__name__ + '('
s += ('lambda=%f)' % self.e_lambda)
return s
def forward(self, x):
b, c, h, w = x.size()
n = w * h - 1
x_minus_mu_square = (x - x.mean(dim=[2, 3], keepdim=True)).pow(2)
y = x_minus_mu_square / (4 * (x_minus_mu_square.sum(dim=[2, 3], keepdim=True) / n + self.e_lambda)) + 0.5
return x * self.activaton(y)