Exemple #1
0
    def __init__(self, in_planes=17, out_planes=8):

        super(SegRefineNet, self).__init__()

        self.conv1 = nn.Sequential(
            conv2d_lrelu(in_planes, out_planes, kernel_size=3, stride=1,
                         pad=1))

        self.classif1 = nn.Conv2d(out_planes,
                                  1,
                                  kernel_size=3,
                                  padding=1,
                                  stride=1,
                                  bias=False)

        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2.0 / n))
            elif isinstance(m, nn.Conv3d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.kernel_size[
                    2] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2.0 / n))
            elif isinstance(m, nn.BatchNorm2d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
            elif isinstance(m, nn.BatchNorm3d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
            elif isinstance(m, nn.Linear):
                m.bias.data.zero_()
Exemple #2
0
    def __init__(self, inplanes, planes, stride, downsample, pad, dilation):

        super(BasicBlock, self).__init__()

        self.conv1 = conv2d_lrelu(inplanes, planes, 3, stride, pad, dilation)
        self.conv2 = conv2d(planes, planes, 3, 1, pad, dilation)

        self.downsample = downsample
        self.stride = stride
Exemple #3
0
    def __init__(self, out_planes=32):

        super(DispRefineNet, self).__init__()

        self.out_planes = out_planes

        self.conv2d_feature = conv2d_lrelu(in_planes=4,
                                           out_planes=self.out_planes,
                                           kernel_size=3,
                                           stride=1,
                                           pad=1,
                                           dilation=1)

        self.residual_astrous_blocks = nn.ModuleList()
        astrous_list = [1, 2, 4, 8, 1, 1]
        for di in astrous_list:
            self.residual_astrous_blocks.append(
                BasicBlock(self.out_planes,
                           self.out_planes,
                           stride=1,
                           downsample=None,
                           pad=1,
                           dilation=di))

        self.conv2d_out = nn.Conv2d(self.out_planes,
                                    1,
                                    kernel_size=3,
                                    stride=1,
                                    padding=1)

        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2.0 / n))
            elif isinstance(m, nn.Conv3d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.kernel_size[
                    2] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2.0 / n))
            elif isinstance(m, nn.BatchNorm2d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
            elif isinstance(m, nn.BatchNorm3d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
            elif isinstance(m, nn.Linear):
                m.bias.data.zero_()

        return