Beispiel #1
0
    def __init__(self,in_channels, out_channels, acti_func, acti_func_param):
        super(UNetBlock, self).__init__()
        
        self.in_chns   = in_channels
        self.out_chns  = out_channels
        self.acti_func = acti_func

        self.conv1 = ConvolutionLayer(in_channels,  out_channels, 3, 
                dim = 2, padding = 1, acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv2 = ConvolutionLayer(out_channels, out_channels, 3, 
                dim = 2, padding = 1, acti_func=get_acti_func(acti_func, acti_func_param))
Beispiel #2
0
    def __init__(self, channels, acti_func, acti_func_param):
        super(PEBlock, self).__init__()

        self.channels  = channels
        self.acti_func = acti_func

        self.conv1 = ConvolutionLayer(channels,  int(channels / 2), 1, 
                dim = 2, padding = 0, conv_group = 1, norm_type = None, norm_group = 1,
                acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv2 = ConvolutionLayer(int(channels / 2),  channels, 1, 
                dim = 2, padding = 0, conv_group = 1, norm_type = None, norm_group = 1,
                acti_func=nn.Sigmoid())
Beispiel #3
0
    def __init__(self,in_channels, out_channels, norm_type, groups, acti_func, acti_func_param):
        super(UNetBlock, self).__init__()
        
        self.in_chns   = in_channels
        self.out_chns  = out_channels
        self.acti_func = acti_func

        group1 = 1 if (in_channels < 8) else groups
        self.conv1 = ConvolutionLayer(in_channels,  out_channels, 1, 
                dim = 2, padding = 0, conv_group = group1, norm_type = norm_type, norm_group = group1,
                acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv2 = ConvolutionLayer(out_channels, out_channels, 3, 
                dim = 2, padding = 1, conv_group = groups, norm_type = norm_type, norm_group = groups,
                acti_func=get_acti_func(acti_func, acti_func_param))
    def __init__(self, in_channels, out_channels, kernel_size, paddding,
                 acti_func, acti_func_param):
        super(ResidualBlock, self).__init__()

        self.in_chns = in_channels
        self.out_chns = out_channels
        self.acti_func = acti_func
        self.relu = nn.ReLU(inplace=True)

        self.conv1 = ConvolutionLayer(in_channels,
                                      out_channels,
                                      kernel_size=kernel_size,
                                      padding=paddding,
                                      acti_func=get_acti_func(
                                          acti_func, acti_func_param))
        self.conv2 = ConvolutionLayer(out_channels,
                                      out_channels,
                                      kernel_size=kernel_size,
                                      padding=paddding,
                                      acti_func=get_acti_func(
                                          acti_func, acti_func_param))
Beispiel #5
0
    def __init__(self, in_channels, out_chnannels,
            dim, resample, acti_func, acti_func_param):
        super(UNetBlock, self).__init__()
        
        self.in_chns   = in_channels
        self.out_chns  = out_chnannels
        self.dim       = dim
        self.resample  = resample  # resample should be 'down', 'up', or None
        self.acti_func = acti_func

        self.conv1 = ConvolutionLayer(in_channels,  out_chnannels, kernel_size = 3, padding=1,
                dim = self.dim, acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv2 = ConvolutionLayer(out_chnannels, out_chnannels, kernel_size = 3, padding=1,
                dim = self.dim, acti_func=get_acti_func(acti_func, acti_func_param))
        if(self.resample == 'down'):
            if(self.dim == 2):
                self.resample_layer = nn.MaxPool2d(kernel_size = 2, stride = 2)
            else:
                self.resample_layer = nn.MaxPool3d(kernel_size = 2, stride = 2)
        elif(self.resample == 'up'):
            self.resample_layer = DeconvolutionLayer(out_chnannels, out_chnannels, kernel_size = 2,
                    dim = self.dim, stride = 2, acti_func = get_acti_func(acti_func, acti_func_param))
        else:
            assert(self.resample == None)
Beispiel #6
0
 def __init__(self,in_channels, out_channels, norm_type, groups, acti_func, acti_func_param):
     super(ResBlock_DWGC_CF, self).__init__()
     self.in_chns   = in_channels
     self.out_chns  = out_channels
     self.acti_func = acti_func
     self.groups    = groups
     groups2        = int(out_channels / groups)
     self.conv1 = ConvolutionLayer(in_channels,  out_channels, 1, 
             dim = 2, padding = 0, conv_group = 1, norm_type = norm_type, norm_group = 1,
             acti_func=get_acti_func(acti_func, acti_func_param))
     self.conv2 = DepthSeperableConvolutionLayer(out_channels, out_channels, 3, 
             dim = 2, padding = 1, conv_group = groups, norm_type = norm_type, norm_group = groups,
             acti_func=get_acti_func(acti_func, acti_func_param))
     self.conv3 = DepthSeperableConvolutionLayer(out_channels, out_channels, 3, 
             dim = 2, padding = 1, conv_group = groups2, norm_type = norm_type, norm_group = groups2,
             acti_func=get_acti_func(acti_func, acti_func_param))
Beispiel #7
0
    def __init__(self,in_channels, out_channels, norm_type, groups, acti_func, acti_func_param):
        super(ResBlock_DWGC_BE_CPF, self).__init__()
        
        self.in_chns   = in_channels
        self.out_chns  = out_channels
        self.acti_func = acti_func

        chns_half = int(out_channels / 2)
        group1 = 1 if (in_channels < 8) else groups
        self.conv1 = ConvolutionLayer(in_channels,  out_channels, 1, 
                dim = 2, padding = 0,conv_group = group1, norm_type = norm_type, norm_group = group1,
                acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv2 = DepthSeperableConvolutionLayer(chns_half, self.out_chns, 3, 
                dim = 2, padding = 1, conv_group = groups, norm_type = norm_type, norm_group = groups,
                acti_func=get_acti_func(acti_func, acti_func_param))
        self.conv3 = DepthSeperableConvolutionLayer(self.out_chns, chns_half, 3, 
                dim = 2, padding = 1, conv_group = groups, norm_type = norm_type, norm_group = groups,
                acti_func=get_acti_func(acti_func, acti_func_param))