def __init__(self, in_channels, out_channels, strides, padding=1, dilation=1, conv1_stride=False, bottleneck_factor=4, data_format="channels_last", **kwargs): super(ResBottleneck, self).__init__(**kwargs) mid_channels = out_channels // bottleneck_factor self.conv1 = conv1x1_block(in_channels=in_channels, out_channels=mid_channels, strides=(strides if conv1_stride else 1), data_format=data_format, name="conv1") self.conv2 = conv3x3_block(in_channels=mid_channels, out_channels=mid_channels, strides=(1 if conv1_stride else strides), padding=padding, dilation=dilation, data_format=data_format, name="conv2") self.conv3 = conv1x1_block(in_channels=mid_channels, out_channels=out_channels, activation=None, data_format=data_format, name="conv3")
def __init__(self, in_channels, out_channels, strides, bottleneck_factor=4, data_format="channels_last", **kwargs): super(ResNeStABottleneck, self).__init__(**kwargs) self.resize = (strides > 1) mid_channels = out_channels // bottleneck_factor self.conv1 = conv1x1_block(in_channels=in_channels, out_channels=mid_channels, data_format=data_format, name="conv1") self.conv2 = saconv3x3_block(in_channels=mid_channels, out_channels=mid_channels, data_format=data_format, name="conv2") if self.resize: self.pool = AvgPool2d(pool_size=3, strides=strides, padding=1, data_format=data_format, name="pool") self.conv3 = conv1x1_block(in_channels=mid_channels, out_channels=out_channels, activation=None, data_format=data_format, name="conv3")
def __init__(self, in_channels, out_channels, strides, cardinality, bottleneck_width, data_format="channels_last", **kwargs): super(SENetBottleneck, self).__init__(**kwargs) mid_channels = out_channels // 4 D = int(math.floor(mid_channels * (bottleneck_width / 64.0))) group_width = cardinality * D group_width2 = group_width // 2 self.conv1 = conv1x1_block(in_channels=in_channels, out_channels=group_width2, data_format=data_format, name="conv1") self.conv2 = conv3x3_block(in_channels=group_width2, out_channels=group_width, strides=strides, groups=cardinality, data_format=data_format, name="conv2") self.conv3 = conv1x1_block(in_channels=group_width, out_channels=out_channels, activation=None, data_format=data_format, name="conv3")
def __init__(self, in_channels, out_channels, strides, conv1_ibn, data_format="channels_last", **kwargs): super(IBNResBottleneck, self).__init__(**kwargs) mid_channels = out_channels // 4 self.conv1 = ibn_conv1x1_block(in_channels=in_channels, out_channels=mid_channels, use_ibn=conv1_ibn, data_format=data_format, name="conv1") self.conv2 = conv3x3_block(in_channels=mid_channels, out_channels=mid_channels, strides=strides, data_format=data_format, name="conv2") self.conv3 = conv1x1_block(in_channels=mid_channels, out_channels=out_channels, activation=None, data_format=data_format, name="conv3")
def __init__(self, in_channels, out_channels, strides, data_format="channels_last", **kwargs): super(ResNeStADownBlock, self).__init__(**kwargs) self.pool = AvgPool2d(pool_size=strides, strides=strides, ceil_mode=True, data_format=data_format, name="pool") self.conv = conv1x1_block(in_channels=in_channels, out_channels=out_channels, activation=None, data_format=data_format, name="conv")
def __init__(self, in_channels, out_channels, strides, padding=1, dilation=1, use_bias=False, use_bn=True, bottleneck=True, conv1_stride=False, data_format="channels_last", **kwargs): super(ResUnit, self).__init__(**kwargs) self.resize_identity = (in_channels != out_channels) or (strides != 1) if bottleneck: self.body = ResBottleneck(in_channels=in_channels, out_channels=out_channels, strides=strides, padding=padding, dilation=dilation, conv1_stride=conv1_stride, data_format=data_format, name="body") else: self.body = ResBlock(in_channels=in_channels, out_channels=out_channels, strides=strides, use_bias=use_bias, use_bn=use_bn, data_format=data_format, name="body") if self.resize_identity: self.identity_conv = conv1x1_block(in_channels=in_channels, out_channels=out_channels, strides=strides, use_bias=use_bias, use_bn=use_bn, activation=None, data_format=data_format, name="identity_conv") self.activ = nn.ReLU()
def __init__(self, in_channels, out_channels, strides, cardinality, bottleneck_width, identity_conv3x3, data_format="channels_last", **kwargs): super(SENetUnit, self).__init__(**kwargs) self.resize_identity = (in_channels != out_channels) or (strides != 1) self.body = SENetBottleneck(in_channels=in_channels, out_channels=out_channels, strides=strides, cardinality=cardinality, bottleneck_width=bottleneck_width, data_format=data_format, name="body") self.se = SEBlock(channels=out_channels, data_format=data_format, name="se") if self.resize_identity: if identity_conv3x3: self.identity_conv = conv3x3_block(in_channels=in_channels, out_channels=out_channels, strides=strides, activation=None, data_format=data_format, name="identity_conv") else: self.identity_conv = conv1x1_block(in_channels=in_channels, out_channels=out_channels, strides=strides, activation=None, data_format=data_format, name="identity_conv") self.activ = nn.ReLU()
def __init__(self, in_channels, out_channels, strides, conv1_ibn, data_format="channels_last", **kwargs): super(IBNResUnit, self).__init__(**kwargs) self.resize_identity = (in_channels != out_channels) or (strides != 1) self.body = IBNResBottleneck(in_channels=in_channels, out_channels=out_channels, strides=strides, conv1_ibn=conv1_ibn, data_format=data_format, name="body") if self.resize_identity: self.identity_conv = conv1x1_block(in_channels=in_channels, out_channels=out_channels, strides=strides, activation=None, data_format=data_format, name="identity_conv") self.activ = nn.ReLU()