示例#1
0
 def __init__(self,
              inplanes,
              planes,
              bn_norm,
              num_splits,
              with_ibn=False,
              with_se=False,
              stride=1,
              downsample=None,
              reduction=16):
     super(Bottleneck, self).__init__()
     self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
     if with_ibn:
         self.bn1 = IBN(planes, bn_norm, num_splits)
     else:
         self.bn1 = get_norm(bn_norm, planes, num_splits)
     self.conv2 = nn.Conv2d(planes,
                            planes,
                            kernel_size=3,
                            stride=stride,
                            padding=1,
                            bias=False)
     self.bn2 = get_norm(bn_norm, planes, num_splits)
     self.conv3 = nn.Conv2d(planes,
                            planes * self.expansion,
                            kernel_size=1,
                            bias=False)
     self.bn3 = get_norm(bn_norm, planes * self.expansion, num_splits)
     self.relu = nn.ReLU(inplace=True)
     if with_se:
         self.se = SELayer(planes * self.expansion, reduction)
     else:
         self.se = nn.Identity()
     self.downsample = downsample
     self.stride = stride
示例#2
0
 def __init__(self, inplanes, planes, bn_norm, norm_opt, num_splits, with_ibn=False, with_se=False,
              stride=1, downsample=None, reduction=16):
     super(BasicBlock, self).__init__()
     self.conv1 = meta_conv2d(inplanes, planes, kernel_size = 3, stride=stride, padding=1, bias=False)
     self.bn1 = meta_norm(bn_norm, planes, norm_opt=norm_opt)
     self.conv2 = meta_conv2d(planes, planes, kernel_size = 3, stride=1, padding=1, bias=False)
     self.bn2 = meta_norm(bn_norm, planes, norm_opt=norm_opt)
     self.relu = nn.ReLU(inplace=True)
     if with_se:
         self.se = SELayer(planes, reduction)
     else:
         self.se = nn.Identity()
     self.downsample = downsample
     self.stride = stride
示例#3
0
 def __init__(self, in_channel, depth, bn_norm, stride, with_se=False):
     super(bottleneck_IR, self).__init__()
     if in_channel == depth:
         self.shortcut_layer = nn.MaxPool2d(1, stride)
     else:
         self.shortcut_layer = nn.Sequential(
             nn.Conv2d(in_channel, depth, (1, 1), stride, bias=False),
             get_norm(bn_norm, depth))
     self.res_layer = nn.Sequential(
         get_norm(bn_norm, in_channel),
         nn.Conv2d(in_channel, depth, (3, 3), (1, 1), 1, bias=False),
         nn.PReLU(depth),
         nn.Conv2d(depth, depth, (3, 3), stride, 1, bias=False),
         get_norm(bn_norm, depth),
         SELayer(depth, 16) if with_se else nn.Identity()
     )