def bn2d(depth, ipabn=None): if ipabn: if ipabn == 'sync': return InPlaceABNSync(depth, activation='none') else: return InPlaceABN(depth, activation='none') else: return nn.BatchNorm2d(depth)
def __init__(self, in_chan, out_chan, ks=3, stride=1, padding=1, *args, **kwargs): super(ConvBNReLU, self).__init__() self.conv = nn.Conv2d(in_chan, out_chan, kernel_size = ks, stride = stride, padding = padding, bias = False) self.bn = InPlaceABNSync(out_chan) self.init_weight()
def __init__(self, in_chan, out_chan, *args, **kwargs): super(AttentionRefinementModule, self).__init__() self.conv = ConvBNReLU(in_chan, out_chan, ks=3, stride=1, padding=1) self.conv_atten = nn.Conv2d(out_chan, out_chan, kernel_size=1, bias=False) self.bn_atten = InPlaceABNSync(out_chan, activation='none') self.sigmoid_atten = nn.Sigmoid() self.init_weight()
def bn_act(depth, with_act, ipabn=None): if ipabn: if with_act: if ipabn == 'sync': res = InPlaceABNSync(depth, activation='relu') else: res = InPlaceABN(depth, activation='relu') else: res = InPlaceABN(depth, activation='none') else: res = nn.BatchNorm2d(depth) return res
def __init__(self, inplanes, planes, stride=1, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes // self.expansion, kernel_size=1, bias=False) self.bn1 = InPlaceABNSync(planes // self.expansion) self.conv2 = nn.Conv2d(planes // self.expansion, planes // self.expansion, kernel_size=3, stride=stride, padding=1, bias=False) self.bn2 = InPlaceABNSync(planes // self.expansion) self.conv3 = nn.Conv2d(planes // self.expansion, planes, kernel_size=1, bias=False) self.bn3 = BatchNorm2d(planes) self.relu = nn.ReLU(inplace=True) self.downsample = downsample self.stride = stride self.drop = nn.Dropout2d(p=drop)
def __init__(self, inplanes, planes, stride=1, rate=1, downsample=None): super(BasicBlock, self).__init__() if inplanes != planes: self.conv0 = conv3x3(inplanes, planes, rate) self.inplanes = inplanes self.planes = planes self.conv1 = conv3x3(planes, planes, stride) self.bn1 = InPlaceABNSync(planes) #self.relu = nn.ReLU(inplace=True) #self.conv2 = conv3x3(planes, planes) self.bn2 = BatchNorm2d(planes) self.downsample = downsample self.stride = stride self.drop = nn.Dropout2d(p=drop)