Esempio n. 1
0
 def __init__(self, name, in_channels, out_channels, stride, dilation):
     super(BasicBlock, self).__init__()
     self.g_name = name
     self.in_channels = in_channels
     self.stride = stride
     channels = out_channels//2
     if stride == 1:
         assert in_channels == out_channels
         self.conv = nn.Sequential(
             slim.conv_bn_relu(name + '/conv1', channels, channels, 1),
             slim.conv_bn(name + '/conv2', 
                 channels, channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=channels),
             slim.conv_bn_relu(name + '/conv3', channels, channels, 1),
         )
     else:
         self.conv = nn.Sequential(
             slim.conv_bn_relu(name + '/conv1', in_channels, channels, 1),
             slim.conv_bn(name + '/conv2', 
                 channels, channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=channels),
             slim.conv_bn_relu(name + '/conv3', channels, channels, 1),
         )
         self.conv0 = nn.Sequential(
             slim.conv_bn(name + '/conv4', 
                 in_channels, in_channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=in_channels),
             slim.conv_bn_relu(name + '/conv5', in_channels, channels, 1),
         )
     self.shuffle = slim.channel_shuffle(name + '/shuffle', 2)
Esempio n. 2
0
    def __init__(self, in_c, out_c, group, stride=2, dilation=1):
        super(BasicUnitA, self).__init__()
        self.stride = stride
        out_c -= in_c
        bottleneck = out_c // 4
        assert bottleneck % group == 0
        assert out_c % group == 0
        assert stride == 2

        self.g_conv1 = slim.conv_bn_relu(in_c,
                                         bottleneck,
                                         1,
                                         stride=1,
                                         pad=0,
                                         group=group)
        self.shuffle2 = slim.get_shuffle(group)
        self.dw_conv3 = slim.conv_bn(bottleneck,
                                     bottleneck,
                                     3,
                                     stride=2,
                                     pad=1,
                                     group=bottleneck)
        self.g_conv4 = slim.conv_bn(bottleneck,
                                    out_c,
                                    1,
                                    stride=1,
                                    pad=0,
                                    group=group)

        self.avg_pool1 = nn.AvgPool2d(3, 2, 1)
 def __init__(self, name, in_channels, out_channels, stride, dilation):
     super(BasicBlock, self).__init__()
     self.g_name = name
     self.in_channels = in_channels
     self.stride = stride
     channels = out_channels//2
     if stride == 1:
         assert in_channels == out_channels
         self.conv = nn.Sequential(
             slim.conv_bn_relu(name + '/conv1', channels, channels, 1),
             slim.conv_bn(name + '/conv2', 
                 channels, channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=channels),
             slim.conv_bn_relu(name + '/conv3', channels, channels, 1),
         )
     else:
         self.conv = nn.Sequential(
             slim.conv_bn_relu(name + '/conv1', in_channels, channels, 1),
             slim.conv_bn(name + '/conv2', 
                 channels, channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=channels),
             slim.conv_bn_relu(name + '/conv3', channels, channels, 1),
         )
         self.conv0 = nn.Sequential(
             slim.conv_bn(name + '/conv4', 
                 in_channels, in_channels, 3, stride=stride, 
                 dilation=dilation, padding=dilation, groups=in_channels),
             slim.conv_bn_relu(name + '/conv5', in_channels, channels, 1),
         )
     self.shuffle = slim.channel_shuffle(name + '/shuffle', 2)
Esempio n. 4
0
 def __init__(self, in_c, out_c, group, stride=1, dilation=1):
     super(BasicUnitB, self).__init__()
     bottleneck = out_c // 4
     assert stride == 1
     #assert in_c == out_c
     assert bottleneck % group == 0
     self.g_conv1 = slim.conv_bn_relu(in_c,
                                      bottleneck,
                                      1,
                                      stride=stride,
                                      pad=0,
                                      group=group)
     self.shuffle2 = slim.get_shuffle(group)
     self.dw_conv3 = slim.conv_bn(bottleneck,
                                  bottleneck,
                                  3,
                                  stride=1,
                                  pad=1,
                                  group=bottleneck)
     self.g_conv4 = slim.conv_bn(bottleneck,
                                 out_c,
                                 1,
                                 stride=1,
                                 pad=0,
                                 group=group)