def __init__(self, inplanes, planes, stride=1, cbam=None, downsample=None): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=3, padding=1, stride=stride) self.bn1 = nn.BatchNorm2d(planes) self.relu = nn.ReLU(inplace=True) self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, padding=1, stride=1) self.bn2 = nn.BatchNorm2d(planes) self.downsample = downsample self.stride = stride if cbam is not None: self.cbam = CBAMLayer(planes) else: self.cbam = None
def __init__(self, inplanes, planes, stride=1, cbam=None, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(planes) self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) self.bn2 = nn.BatchNorm2d(planes) self.conv3 = nn.Conv2d(planes, planes * Bottleneck.expansion, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(planes * Bottleneck.expansion) self.relu = nn.ReLU(inplace=True) self.downsample = downsample self.stride = stride if cbam is not None: self.cbam = CBAMLayer(planes * Bottleneck.expansion) else: self.cbam = None