示例#1
0
def attngatingblock(x, g, inputfilters, outfilters, scale_factor, phase, image_z=None, height=None, width=None,
                    scope=None):
    """
    take g which is the spatially smaller signal, do a conv to get the same number of feature channels as x (bigger spatially)
    do a conv on x to also get same feature channels (theta_x)
    then, upsample g to be same size as x add x and g (concat_xg) relu, 1x1x1 conv, then sigmoid then upsample the final -
    this gives us attn coefficients
    :param x:
    :param g:
    :param inputfilters:
    :param outfilters:
    :param scale_factor:2
    :param scope:
    :return:
    """
    with tf.name_scope(scope):
        kernalx = (1, 1, 1, inputfilters, outfilters)
        Wx = weight_xavier_init(shape=kernalx, n_inputs=kernalx[0] * kernalx[1] * kernalx[2] * kernalx[3],
                                n_outputs=kernalx[-1], activefunction='relu', variable_name=scope + 'conv_Wx')
        Bx = bias_variable([kernalx[-1]], variable_name=scope + 'conv_Bx')
        theta_x = conv3d(x, Wx, scale_factor) + Bx
        kernalg = (1, 1, 1, inputfilters, outfilters)
        Wg = weight_xavier_init(shape=kernalg, n_inputs=kernalg[0] * kernalg[1] * kernalg[2] * kernalg[3],
                                n_outputs=kernalg[-1], activefunction='relu', variable_name=scope + 'conv_Wg')
        Bg = bias_variable([kernalg[-1]], variable_name=scope + 'conv_Bg')
        phi_g = conv3d(g, Wg) + Bg

        add_xg = resnet_Add(theta_x, phi_g)
        act_xg = tf.nn.relu(add_xg)

        kernalpsi = (1, 1, 1, outfilters, 1)
        Wpsi = weight_xavier_init(shape=kernalpsi, n_inputs=kernalpsi[0] * kernalpsi[1] * kernalpsi[2] * kernalpsi[3],
                                  n_outputs=kernalpsi[-1], activefunction='relu', variable_name=scope + 'conv_Wpsi')
        Bpsi = bias_variable([kernalpsi[-1]], variable_name=scope + 'conv_Bpsi')
        psi = conv3d(act_xg, Wpsi) + Bpsi
        sigmoid_psi = tf.nn.sigmoid(psi)

        upsample_psi = upsample3d(sigmoid_psi, scale_factor=scale_factor, scope=scope + "resampler")

        # Attention: upsample_psi * x
        # upsample_psi = layers.Lambda(lambda x, repnum: K.repeat_elements(x, repnum, axis=4),
        #                              arguments={'repnum': outfilters})(upsample_psi)
        gat_x = tf.multiply(upsample_psi, x)
        kernal_gat_x = (1, 1, 1, outfilters, outfilters)
        Wgatx = weight_xavier_init(shape=kernal_gat_x,
                                   n_inputs=kernal_gat_x[0] * kernal_gat_x[1] * kernal_gat_x[2] * kernal_gat_x[3],
                                   n_outputs=kernal_gat_x[-1], activefunction='relu',
                                   variable_name=scope + 'conv_Wgatx')
        Bgatx = bias_variable([kernalpsi[-1]], variable_name=scope + 'conv_Bgatx')
        gat_x_out = conv3d(gat_x, Wgatx) + Bgatx
        gat_x_out = normalizationlayer(gat_x_out, is_train=phase, height=height, width=width, image_z=image_z,
                                       norm_type='group', scope=scope)
    return gat_x_out
示例#2
0
def positionAttentionblock(x, inputfilters, outfilters, kernal_size=1, scope=None):
    """
    Position attention module
    :param x:
    :param inputfilters:inputfilter number
    :param outfilters:outputfilter number
    :param scope:
    :return:
    """
    with tf.name_scope(scope):
        m_batchsize, Z, H, W, C = x.get_shape().as_list()

        kernalquery = (kernal_size, kernal_size, kernal_size, inputfilters, outfilters)
        Wquery = weight_xavier_init(shape=kernalquery,
                                    n_inputs=kernalquery[0] * kernalquery[1] * kernalquery[2] * kernalquery[3],
                                    n_outputs=kernalquery[-1], activefunction='relu',
                                    variable_name=scope + 'conv_Wquery')
        Bquery = bias_variable([kernalquery[-1]], variable_name=scope + 'conv_Bquery')
        query_conv = conv3d(x, Wquery) + Bquery
        query_conv_new = tf.reshape(query_conv, [-1, Z * H * W])

        kernalkey = (kernal_size, kernal_size, kernal_size, inputfilters, outfilters)
        Wkey = weight_xavier_init(shape=kernalkey, n_inputs=kernalkey[0] * kernalkey[1] * kernalkey[2] * kernalkey[3],
                                  n_outputs=kernalkey[-1], activefunction='relu', variable_name=scope + 'conv_Wkey')
        Bkey = bias_variable([kernalkey[-1]], variable_name=scope + 'conv_Bkey')
        key_conv = conv3d(x, Wkey) + Bkey
        key_conv_new = tf.reshape(key_conv, [-1, Z * H * W])

        # OOM,such as 512x512x32 then matric is 8388608x8388608
        # key_conv_new = tf.transpose(key_conv_new, [0, 2, 1])
        # (2,2,2,3)*(2,2,3,4)=(2,2,2,4),(2,2,3)*(2,3,4)=(2,2,4)
        # energy = tf.matmul(query_conv_new, key_conv_new)  # (m_batchsize,Z*H*W,Z*H*W)

        energy = tf.multiply(query_conv_new, key_conv_new)
        attention = tf.nn.sigmoid(energy)

        kernalproj = (kernal_size, kernal_size, kernal_size, inputfilters, outfilters)
        Wproj = weight_xavier_init(shape=kernalproj,
                                   n_inputs=kernalproj[0] * kernalproj[1] * kernalproj[2] * kernalproj[3],
                                   n_outputs=kernalproj[-1], activefunction='relu', variable_name=scope + 'conv_Wproj')
        Bproj = bias_variable([kernalproj[-1]], variable_name=scope + 'conv_Bproj')
        proj_value = conv3d(x, Wproj) + Bproj
        proj_value_new = tf.reshape(proj_value, [-1, Z * H * W])

        out = tf.multiply(attention, proj_value_new)
        out_new = tf.reshape(out, [-1, Z, H, W, C])

        out_new = resnet_Add(out_new, x)
        return out_new
示例#3
0
def channelAttentionblock(x, scope=None):
    """
    Channel attention module
    :param x:input
    :param scope: scope name
    :return:channelattention result
    """
    with tf.name_scope(scope):
        m_batchsize, Z, H, W, C = x.get_shape().as_list()

        proj_query = tf.reshape(x, [-1, C])
        proj_key = tf.reshape(x, [-1, C])
        proj_query = tf.transpose(proj_query, [1, 0])

        energy = tf.matmul(proj_query, proj_key)  # (C,C)
        attention = tf.nn.sigmoid(energy)

        proj_value = tf.reshape(x, [-1, C])
        proj_value = tf.transpose(proj_value, [1, 0])
        out = tf.matmul(attention, proj_value)  # (C,-1)

        out = tf.reshape(out, [-1, Z, H, W, C])
        out = resnet_Add(out, x)
        return out
def _create_conv_net(X, image_z, image_width, image_height, image_channel, phase, drop, n_class=1):
    inputX = tf.reshape(X, [-1, image_z, image_width, image_height, image_channel])  # shape=(?, 32, 32, 1)
    # Vnet model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX, kernal=(3, 3, 3, image_channel, 16), phase=phase, drop=drop,
                               scope='layer0')
    layer1 = conv_bn_relu_drop(x=layer0, kernal=(3, 3, 3, 16, 16), phase=phase, drop=drop,
                               scope='layer1')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1, kernal=(3, 3, 3, 16, 32), phase=phase, drop=drop, scope='down1')
    # layer2->convolution
    layer2 = conv_bn_relu_drop(x=down1, kernal=(3, 3, 3, 32, 32), phase=phase, drop=drop,
                               scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2, kernal=(3, 3, 3, 32, 32), phase=phase, drop=drop,
                               scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2, kernal=(3, 3, 3, 32, 64), phase=phase, drop=drop, scope='down2')
    # layer3->convolution
    layer3 = conv_bn_relu_drop(x=down2, kernal=(3, 3, 3, 64, 64), phase=phase, drop=drop,
                               scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3, kernal=(3, 3, 3, 64, 64), phase=phase, drop=drop,
                               scope='layer3_2')
    layer3 = conv_bn_relu_drop(x=layer3, kernal=(3, 3, 3, 64, 64), phase=phase, drop=drop,
                               scope='layer3_3')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3, kernal=(3, 3, 3, 64, 128), phase=phase, drop=drop, scope='down3')
    # layer4->convolution
    layer4 = conv_bn_relu_drop(x=down3, kernal=(3, 3, 3, 128, 128), phase=phase, drop=drop,
                               scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4, kernal=(3, 3, 3, 128, 128), phase=phase, drop=drop,
                               scope='layer4_2')
    layer4 = conv_bn_relu_drop(x=layer4, kernal=(3, 3, 3, 128, 128), phase=phase, drop=drop,
                               scope='layer4_3')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4, kernal=(3, 3, 3, 128, 256), phase=phase, drop=drop, scope='down4')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4, kernal=(3, 3, 3, 256, 256), phase=phase, drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5, kernal=(3, 3, 3, 256, 256), phase=phase, drop=drop,
                               scope='layer5_2')
    layer5 = conv_bn_relu_drop(x=layer5, kernal=(3, 3, 3, 256, 256), phase=phase, drop=drop,
                               scope='layer5_3')
    layer5 = resnet_Add(x1=down4, x2=layer5)

    # layer9->deconvolution
    deconv1 = deconv_relu(x=layer5, kernal=(3, 3, 3, 128, 256), scope='deconv1')
    # layer8->convolution
    layer6 = crop_and_concat(layer4, deconv1)
    _, Z, H, W, _ = layer4.get_shape().as_list()
    layer6 = conv_bn_relu_drop(x=layer6, kernal=(3, 3, 3, 256, 128), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer6_1')
    layer6 = conv_bn_relu_drop(x=layer6, kernal=(3, 3, 3, 128, 128), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer6_2')
    layer6 = conv_bn_relu_drop(x=layer6, kernal=(3, 3, 3, 128, 128), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer6_3')
    layer6 = resnet_Add(x1=deconv1, x2=layer6)
    # layer9->deconvolution
    deconv2 = deconv_relu(x=layer6, kernal=(3, 3, 3, 64, 128), scope='deconv2')
    # layer8->convolution
    layer7 = crop_and_concat(layer3, deconv2)
    _, Z, H, W, _ = layer3.get_shape().as_list()
    layer7 = conv_bn_relu_drop(x=layer7, kernal=(3, 3, 3, 128, 64), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer7_1')
    layer7 = conv_bn_relu_drop(x=layer7, kernal=(3, 3, 3, 64, 64), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer7_2')
    layer7 = resnet_Add(x1=deconv2, x2=layer7)
    # layer9->deconvolution
    deconv3 = deconv_relu(x=layer7, kernal=(3, 3, 3, 32, 64), scope='deconv3')
    # layer8->convolution
    layer8 = crop_and_concat(layer2, deconv3)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer8 = conv_bn_relu_drop(x=layer8, kernal=(3, 3, 3, 64, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer10_1')
    layer8 = conv_bn_relu_drop(x=layer8, kernal=(3, 3, 3, 32, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer10_2')
    layer8 = conv_bn_relu_drop(x=layer8, kernal=(3, 3, 3, 32, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer10_3')
    layer8 = resnet_Add(x1=deconv3, x2=layer8)
    # layer9->deconvolution
    deconv4 = deconv_relu(x=layer8, kernal=(3, 3, 3, 16, 32), scope='deconv4')
    # layer8->convolution
    layer9 = crop_and_concat(layer1, deconv4)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer9 = conv_bn_relu_drop(x=layer9, kernal=(3, 3, 3, 32, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer11_1')
    layer9 = conv_bn_relu_drop(x=layer9, kernal=(3, 3, 3, 32, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer11_2')
    layer9 = conv_bn_relu_drop(x=layer9, kernal=(3, 3, 3, 32, 32), image_z=Z, height=H, width=W, phase=phase,
                               drop=drop, scope='layer11_3')
    layer9 = resnet_Add(x1=deconv4, x2=layer9)
    # layer14->output
    output_map = conv_sigmod(x=layer9, kernal=(1, 1, 1, 32, n_class), scope='output')
    return output_map
示例#5
0
def mutildepthModel(x,
                    featuremap,
                    phase,
                    drop,
                    image_z=None,
                    height=None,
                    width=None,
                    scope=None):
    kernal = (3, 3, 3, featuremap, featuremap)

    branch1 = conv_bn_relu_drop(x,
                                kernal=kernal,
                                phase=phase,
                                drop=drop,
                                image_z=image_z,
                                height=height,
                                width=width,
                                scope=scope + 'branch1')

    branch2 = conv_bn_relu_drop(x,
                                kernal=kernal,
                                phase=phase,
                                drop=drop,
                                image_z=image_z,
                                height=height,
                                width=width,
                                scope=scope + 'branch2')
    branch3 = conv_bn_relu_drop(x,
                                kernal=kernal,
                                phase=phase,
                                drop=drop,
                                image_z=image_z,
                                height=height,
                                width=width,
                                scope=scope + 'branch3')
    branch3_1 = conv_bn_relu_drop(branch3,
                                  kernal=kernal,
                                  phase=phase,
                                  drop=drop,
                                  image_z=image_z,
                                  height=height,
                                  width=width,
                                  scope=scope + 'branch3_1')
    branch3_1 = (branch2 + branch3_1) / 2.

    branch2_1 = conv_bn_relu_drop(branch3_1,
                                  kernal=kernal,
                                  phase=phase,
                                  drop=drop,
                                  image_z=image_z,
                                  height=height,
                                  width=width,
                                  scope=scope + 'branch2_1')
    branch3_2 = conv_bn_relu_drop(branch3_1,
                                  kernal=kernal,
                                  phase=phase,
                                  drop=drop,
                                  image_z=image_z,
                                  height=height,
                                  width=width,
                                  scope=scope + 'branch3_2')
    branch3_3 = conv_bn_relu_drop(branch3_2,
                                  kernal=kernal,
                                  phase=phase,
                                  drop=drop,
                                  image_z=image_z,
                                  height=height,
                                  width=width,
                                  scope=scope + 'branch3_3')
    branch3_3 = (branch3_3 + branch2_1 + branch1) / 3.

    branch3_4 = conv_bn_relu_drop(branch3_3,
                                  kernal=kernal,
                                  phase=phase,
                                  drop=drop,
                                  image_z=image_z,
                                  height=height,
                                  width=width,
                                  scope=scope + 'branch3_4')
    output = resnet_Add(x, branch3_4)
    return output
示例#6
0
def _create_mutildepth_conv_net(X,
                                image_z,
                                image_width,
                                image_height,
                                image_channel,
                                phase,
                                drop,
                                n_class=2):
    inputX = tf.reshape(
        X, [-1, image_z, image_width, image_height, image_channel
            ])  # shape=(?, 32, 32, 1)
    # Vnet model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX,
                               kernal=(3, 3, 3, image_channel, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer0')
    layer1 = conv_bn_relu_drop(x=layer0,
                               kernal=(3, 3, 3, 20, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer1')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1,
                          kernal=(3, 3, 3, 20, 40),
                          phase=phase,
                          drop=drop,
                          scope='down1')
    # layer2->convolution
    layer2 = mutildepthModel(x=down1,
                             featuremap=40,
                             phase=phase,
                             drop=drop,
                             scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2,
                               kernal=(3, 3, 3, 40, 40),
                               phase=phase,
                               drop=drop,
                               scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2,
                          kernal=(3, 3, 3, 40, 80),
                          phase=phase,
                          drop=drop,
                          scope='down2')
    # layer3->convolution
    layer3 = mutildepthModel(x=down2,
                             featuremap=80,
                             phase=phase,
                             drop=drop,
                             scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_2')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3,
                          kernal=(3, 3, 3, 80, 160),
                          phase=phase,
                          drop=drop,
                          scope='down3')
    # layer4->convolution
    layer4 = mutildepthModel(x=down3,
                             featuremap=160,
                             phase=phase,
                             drop=drop,
                             scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_2')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4,
                          kernal=(3, 3, 3, 160, 320),
                          phase=phase,
                          drop=drop,
                          scope='down4')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_2')
    layer5 = resnet_Add(x1=down4, x2=layer5)
    # layer9->deconvolution
    deconv1 = deconv_relu(x=layer5,
                          kernal=(3, 3, 3, 160, 320),
                          scope='deconv1')
    # layer8->convolution
    layer6 = crop_and_concat(layer4, deconv1)
    _, Z, H, W, _ = layer4.get_shape().as_list()
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 320, 160),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_1')
    layer6 = mutildepthModel(x=layer6,
                             featuremap=160,
                             phase=phase,
                             drop=drop,
                             image_z=Z,
                             height=H,
                             width=W,
                             scope='layer6_2')
    layer6 = resnet_Add(x1=deconv1, x2=layer6)
    # layer9->deconvolution
    deconv2 = deconv_relu(x=layer6, kernal=(3, 3, 3, 80, 160), scope='deconv2')
    # layer8->convolution
    layer7 = crop_and_concat(layer3, deconv2)
    _, Z, H, W, _ = layer3.get_shape().as_list()
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 160, 80),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_1')
    layer7 = mutildepthModel(x=layer7,
                             featuremap=80,
                             phase=phase,
                             drop=drop,
                             image_z=Z,
                             height=H,
                             width=W,
                             scope='layer7_2')
    layer7 = resnet_Add(x1=deconv2, x2=layer7)
    # layer9->deconvolution
    deconv3 = deconv_relu(x=layer7, kernal=(3, 3, 3, 40, 80), scope='deconv3')
    # layer8->convolution
    layer8 = crop_and_concat(layer2, deconv3)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 80, 40),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_1')
    layer8 = mutildepthModel(x=layer8,
                             featuremap=40,
                             phase=phase,
                             drop=drop,
                             image_z=Z,
                             height=H,
                             width=W,
                             scope='layer8_2')
    layer8 = resnet_Add(x1=deconv3, x2=layer8)
    # layer9->deconvolution
    deconv4 = deconv_relu(x=layer8, kernal=(3, 3, 3, 20, 40), scope='deconv4')
    # layer8->convolution
    layer9 = crop_and_concat(layer1, deconv4)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 40, 20),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_1')
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 20, 20),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_2')
    layer9 = resnet_Add(x1=deconv4, x2=layer9)
    # layer14->output
    output_map = conv_softmax(x=layer9,
                              kernal=(1, 1, 1, 20, n_class),
                              scope='output')
    return output_map
示例#7
0
def _create_dualattention_conv_net(X,
                                   image_z,
                                   image_width,
                                   image_height,
                                   image_channel,
                                   phase,
                                   drop,
                                   n_class=1):
    inputX = tf.reshape(
        X, [-1, image_z, image_width, image_height, image_channel
            ])  # shape=(?, 32, 32, 1)
    # Vnet model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX,
                               kernal=(3, 3, 3, image_channel, 16),
                               phase=phase,
                               drop=drop,
                               scope='layer0')
    layer1 = conv_bn_relu_drop(x=layer0,
                               kernal=(3, 3, 3, 16, 16),
                               phase=phase,
                               drop=drop,
                               scope='layer1')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1,
                          kernal=(3, 3, 3, 16, 32),
                          phase=phase,
                          drop=drop,
                          scope='down1')
    # layer2->convolution
    layer2 = conv_bn_relu_drop(x=down1,
                               kernal=(3, 3, 3, 32, 32),
                               phase=phase,
                               drop=drop,
                               scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2,
                               kernal=(3, 3, 3, 32, 32),
                               phase=phase,
                               drop=drop,
                               scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2,
                          kernal=(3, 3, 3, 32, 64),
                          phase=phase,
                          drop=drop,
                          scope='down2')
    # layer3->convolution
    layer3 = conv_bn_relu_drop(x=down2,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_2')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_3')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3,
                          kernal=(3, 3, 3, 64, 128),
                          phase=phase,
                          drop=drop,
                          scope='down3')
    # layer4->convolution
    layer4 = conv_bn_relu_drop(x=down3,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_2')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_3')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4,
                          kernal=(3, 3, 3, 128, 256),
                          phase=phase,
                          drop=drop,
                          scope='down4')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_2')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_3')
    layer5 = resnet_Add(x1=down4, x2=layer5)
    # layer9->deconvolution
    deconv1 = deconv_relu(x=layer5,
                          kernal=(3, 3, 3, 128, 256),
                          scope='deconv1')
    # dual model1
    pos_attenfeat1 = conv_bn_relu_drop(x=layer4,
                                       kernal=(3, 3, 3, 128, 128 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer1_1')
    pos_attenfeat1 = positionAttentionblock(pos_attenfeat1,
                                            128 // 2,
                                            128 // 2,
                                            scope='dual_pos_atten1')
    pos_attenfeat1 = conv_bn_relu_drop(x=pos_attenfeat1,
                                       kernal=(3, 3, 3, 128 // 2, 128 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer1_2')

    cha_attenfeat1 = conv_bn_relu_drop(x=layer4,
                                       kernal=(3, 3, 3, 128, 128 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer1_3')
    cha_attenfeat1 = channelAttentionblock(cha_attenfeat1,
                                           scope='dual_cha_atten1')
    cha_attenfeat1 = conv_bn_relu_drop(x=cha_attenfeat1,
                                       kernal=(3, 3, 3, 128 // 2, 128 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer1_4')

    feat_sum1 = resnet_Add(pos_attenfeat1, cha_attenfeat1)
    sasc_output1 = conv_bn_relu_drop(x=feat_sum1,
                                     kernal=(1, 1, 1, 128 // 2, 128),
                                     phase=phase,
                                     drop=drop,
                                     scope='dual_layer1_5')
    # layer8->convolution
    layer6 = crop_and_concat(sasc_output1, deconv1)
    _, Z, H, W, _ = sasc_output1.get_shape().as_list()
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 256, 128),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_1')
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 128, 128),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_2')
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 128, 128),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_3')
    layer6 = resnet_Add(x1=deconv1, x2=layer6)

    # layer9->deconvolution
    deconv2 = deconv_relu(x=layer6, kernal=(3, 3, 3, 64, 128), scope='deconv2')
    # dual model2
    pos_attenfeat2 = conv_bn_relu_drop(x=layer3,
                                       kernal=(3, 3, 3, 64, 64 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer2_1')
    pos_attenfeat2 = positionAttentionblock(pos_attenfeat2,
                                            64 // 2,
                                            64 // 2,
                                            scope='dual_pos_atten2')
    pos_attenfeat2 = conv_bn_relu_drop(x=pos_attenfeat2,
                                       kernal=(3, 3, 3, 64 // 2, 64 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer2_2')
    cha_attenfeat2 = conv_bn_relu_drop(x=layer3,
                                       kernal=(3, 3, 3, 64, 64 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer2_3')
    cha_attenfeat2 = channelAttentionblock(cha_attenfeat2,
                                           scope='dual_cha_atten2')
    cha_attenfeat2 = conv_bn_relu_drop(x=cha_attenfeat2,
                                       kernal=(3, 3, 3, 64 // 2, 64 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer2_4')
    feat_sum2 = resnet_Add(pos_attenfeat2, cha_attenfeat2)
    sasc_output2 = conv_bn_relu_drop(x=feat_sum2,
                                     kernal=(1, 1, 1, 64 // 2, 64),
                                     phase=phase,
                                     drop=drop,
                                     scope='dual_layer2_5')
    # layer8->convolution
    layer7 = crop_and_concat(sasc_output2, deconv2)
    _, Z, H, W, _ = sasc_output2.get_shape().as_list()
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 128, 64),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_1')
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 64, 64),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_2')
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 64, 64),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_3')
    layer7 = resnet_Add(x1=deconv2, x2=layer7)
    # layer9->deconvolution
    deconv3 = deconv_relu(x=layer7, kernal=(3, 3, 3, 32, 64), scope='deconv3')
    # dual model3
    pos_attenfeat3 = conv_bn_relu_drop(x=layer2,
                                       kernal=(3, 3, 3, 32, 32 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer3_1')
    pos_attenfeat3 = positionAttentionblock(pos_attenfeat3,
                                            32 // 2,
                                            32 // 2,
                                            scope='dual_pos_atten3')
    pos_attenfeat3 = conv_bn_relu_drop(x=pos_attenfeat3,
                                       kernal=(3, 3, 3, 32 // 2, 32 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer3_2')
    cha_attenfeat3 = conv_bn_relu_drop(x=layer2,
                                       kernal=(3, 3, 3, 32, 32 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer3_3')
    cha_attenfeat3 = channelAttentionblock(cha_attenfeat3,
                                           scope='dual_cha_atten3')
    cha_attenfeat3 = conv_bn_relu_drop(x=cha_attenfeat3,
                                       kernal=(3, 3, 3, 32 // 2, 32 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer3_4')
    feat_sum3 = resnet_Add(pos_attenfeat3, cha_attenfeat3)
    sasc_output3 = conv_bn_relu_drop(x=feat_sum3,
                                     kernal=(1, 1, 1, 32 // 2, 32),
                                     phase=phase,
                                     drop=drop,
                                     scope='dual_layer3_5')
    # layer8->convolution
    layer8 = crop_and_concat(sasc_output3, deconv3)
    _, Z, H, W, _ = sasc_output3.get_shape().as_list()
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 64, 32),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_1')
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 32, 32),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_2')
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 32, 32),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_3')
    layer8 = resnet_Add(x1=deconv3, x2=layer8)
    # layer9->deconvolution
    deconv4 = deconv_relu(x=layer8, kernal=(3, 3, 3, 16, 32), scope='deconv4')
    # dual model4
    pos_attenfeat4 = conv_bn_relu_drop(x=layer1,
                                       kernal=(3, 3, 3, 16, 16 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer4_1')
    pos_attenfeat4 = positionAttentionblock(pos_attenfeat4,
                                            16 // 2,
                                            16 // 2,
                                            scope='dual_pos_atten4')
    pos_attenfeat4 = conv_bn_relu_drop(x=pos_attenfeat4,
                                       kernal=(3, 3, 3, 16 // 2, 16 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer4_2')
    cha_attenfeat4 = conv_bn_relu_drop(x=layer1,
                                       kernal=(3, 3, 3, 16, 16 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer4_3')
    cha_attenfeat4 = channelAttentionblock(cha_attenfeat4,
                                           scope='dual_cha_atten4')
    cha_attenfeat4 = conv_bn_relu_drop(x=cha_attenfeat4,
                                       kernal=(3, 3, 3, 16 // 2, 16 // 2),
                                       phase=phase,
                                       drop=drop,
                                       scope='dual_layer4_4')
    feat_sum4 = resnet_Add(pos_attenfeat4, cha_attenfeat4)
    sasc_output4 = conv_bn_relu_drop(x=feat_sum4,
                                     kernal=(1, 1, 1, 16 // 2, 16),
                                     phase=phase,
                                     drop=drop,
                                     scope='dual_layer4_5')
    # layer8->convolution
    layer9 = crop_and_concat(sasc_output4, deconv4)
    _, Z, H, W, _ = sasc_output4.get_shape().as_list()
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 32, 16),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_1')
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 16, 16),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_2')
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 16, 16),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_3')
    layer9 = resnet_Add(x1=deconv4, x2=layer9)
    # layer14->output
    output_map = conv_sigmod(x=layer9,
                             kernal=(1, 1, 1, 16, n_class),
                             scope='output')
    return output_map
def _create_convtripleplus_net(X,
                               image_z,
                               image_width,
                               image_height,
                               image_channel,
                               phase,
                               drop,
                               n_class=2):
    inputX = tf.reshape(
        X, [-1, image_z, image_width, image_height, image_channel
            ])  # shape=(?, 32, 32, 1)
    # Vnettripleplus model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX,
                               kernal=(3, 3, 3, image_channel, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer1_1')
    layer1 = conv_bn_relu_drop(x=layer0,
                               kernal=(3, 3, 3, 20, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer1_2')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1,
                          kernal=(3, 3, 3, 20, 40),
                          phase=phase,
                          drop=drop,
                          scope='down1')
    # layer2->convolution
    layer2 = conv_bn_relu_drop(x=down1,
                               kernal=(3, 3, 3, 40, 40),
                               phase=phase,
                               drop=drop,
                               scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2,
                               kernal=(3, 3, 3, 40, 40),
                               phase=phase,
                               drop=drop,
                               scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2,
                          kernal=(3, 3, 3, 40, 80),
                          phase=phase,
                          drop=drop,
                          scope='down2')
    # layer3->convolution
    layer3 = conv_bn_relu_drop(x=down2,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_2')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_3')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3,
                          kernal=(3, 3, 3, 80, 160),
                          phase=phase,
                          drop=drop,
                          scope='down3')
    # layer4->convolution
    layer4 = conv_bn_relu_drop(x=down3,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_2')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_4')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4,
                          kernal=(3, 3, 3, 160, 320),
                          phase=phase,
                          drop=drop,
                          scope='down4')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_2')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_3')
    layer5 = resnet_Add(x1=down4, x2=layer5)

    _, Z, H, W, _ = layer4.get_shape().as_list()
    # layer9->decode1
    upsample1_1 = upsample3d(x=layer5, scale_factor=2, scope='upsample1_1')
    decode1_1 = conv_bn_relu_drop(upsample1_1,
                                  kernal=(3, 3, 3, 160, 32),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode1_1')
    decode1_2 = conv_bn_relu_drop(layer4,
                                  kernal=(3, 3, 3, 160, 32),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode1_2')
    decode1_3 = max_pool3d(x=layer3, depth=True)
    decode1_3 = conv_bn_relu_drop(decode1_3,
                                  kernal=(3, 3, 3, 80, 32),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode1_3')
    decode1_4 = max_pool3d(x=layer2, depth=True)
    decode1_4 = max_pool3d(x=decode1_4, depth=True)
    decode1_4 = conv_bn_relu_drop(decode1_4,
                                  kernal=(3, 3, 3, 40, 32),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode1_4')
    decode1_5 = max_pool3d(x=layer1, depth=True)
    decode1_5 = max_pool3d(x=decode1_5, depth=True)
    decode1_5 = max_pool3d(x=decode1_5, depth=True)
    decode1_5 = conv_bn_relu_drop(decode1_5,
                                  kernal=(3, 3, 3, 20, 32),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode1_5')

    decode1 = tf.concat(
        [decode1_1, decode1_2, decode1_3, decode1_4, decode1_5], axis=4)
    decode1 = conv_bn_relu_drop(x=decode1,
                                kernal=(3, 3, 3, 160, 160),
                                image_z=Z,
                                height=H,
                                width=W,
                                phase=phase,
                                drop=drop,
                                scope='decode1_6')
    # layer9->decode2
    _, Z, H, W, _ = layer3.get_shape().as_list()
    upsample2_1 = upsample3d(x=layer5, scale_factor=4, scope='upsample2_1')
    decode2_1 = conv_bn_relu_drop(upsample2_1,
                                  kernal=(3, 3, 3, 80, 16),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode2_1')
    decode2_2 = upsample3d(x=decode1, scale_factor=2, scope='upsample2_2')
    decode2_2 = conv_bn_relu_drop(decode2_2,
                                  kernal=(3, 3, 3, 80, 16),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode2_2')
    decode2_3 = conv_bn_relu_drop(layer3,
                                  kernal=(3, 3, 3, 80, 16),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode2_3')
    decode2_4 = max_pool3d(x=layer2, depth=True)
    decode2_4 = conv_bn_relu_drop(decode2_4,
                                  kernal=(3, 3, 3, 40, 16),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode2_4')
    decode2_5 = max_pool3d(x=layer1, depth=True)
    decode2_5 = max_pool3d(x=decode2_5, depth=True)
    decode2_5 = conv_bn_relu_drop(decode2_5,
                                  kernal=(3, 3, 3, 20, 16),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode2_5')

    decode2 = tf.concat(
        [decode2_1, decode2_2, decode2_3, decode2_4, decode2_5], axis=4)
    decode2 = conv_bn_relu_drop(x=decode2,
                                kernal=(3, 3, 3, 80, 80),
                                image_z=Z,
                                height=H,
                                width=W,
                                phase=phase,
                                drop=drop,
                                scope='decode2_6')
    # layer9->decode3
    _, Z, H, W, _ = layer2.get_shape().as_list()
    upsample3_1 = upsample3d(x=layer5, scale_factor=8, scope='upsample3_1')
    decode3_1 = conv_bn_relu_drop(upsample3_1,
                                  kernal=(3, 3, 3, 40, 8),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode3_1')
    decode3_2 = upsample3d(x=decode1, scale_factor=4, scope='upsample3_2')
    decode3_2 = conv_bn_relu_drop(decode3_2,
                                  kernal=(3, 3, 3, 40, 8),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode3_2')
    decode3_3 = upsample3d(x=decode2, scale_factor=2, scope='upsample3_3')
    decode3_3 = conv_bn_relu_drop(decode3_3,
                                  kernal=(3, 3, 3, 40, 8),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode3_3')
    decode3_4 = conv_bn_relu_drop(layer2,
                                  kernal=(3, 3, 3, 40, 8),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode3_4')
    decode3_5 = max_pool3d(x=layer1, depth=True)
    decode3_5 = conv_bn_relu_drop(decode3_5,
                                  kernal=(3, 3, 3, 20, 8),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode3_5')

    decode3 = tf.concat(
        [decode3_1, decode3_2, decode3_3, decode3_4, decode3_5], axis=4)
    decode3 = conv_bn_relu_drop(x=decode3,
                                kernal=(3, 3, 3, 40, 40),
                                image_z=Z,
                                height=H,
                                width=W,
                                phase=phase,
                                drop=drop,
                                scope='decode3_6')
    # layer9->decode4
    _, Z, H, W, _ = layer1.get_shape().as_list()
    upsample4_1 = upsample3d(x=layer5, scale_factor=16, scope='upsample4_1')
    decode4_1 = conv_bn_relu_drop(upsample4_1,
                                  kernal=(3, 3, 3, 20, 4),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode4_1')
    decode4_2 = upsample3d(x=decode1, scale_factor=8, scope='upsample4_2')
    decode4_2 = conv_bn_relu_drop(decode4_2,
                                  kernal=(3, 3, 3, 20, 4),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode4_2')
    decode4_3 = upsample3d(x=decode2, scale_factor=4, scope='upsample4_3')
    decode4_3 = conv_bn_relu_drop(decode4_3,
                                  kernal=(3, 3, 3, 20, 4),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode4_3')
    decode4_4 = upsample3d(x=decode3, scale_factor=2, scope='upsample4_4')
    decode4_4 = conv_bn_relu_drop(decode4_4,
                                  kernal=(3, 3, 3, 20, 4),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode4_4')
    decode4_5 = conv_bn_relu_drop(layer1,
                                  kernal=(3, 3, 3, 20, 4),
                                  image_z=Z,
                                  height=H,
                                  width=W,
                                  phase=phase,
                                  drop=drop,
                                  scope='decode4_5')

    decode4 = tf.concat(
        [decode4_1, decode4_2, decode4_3, decode4_4, decode4_5], axis=4)
    decode4 = conv_bn_relu_drop(x=decode4,
                                kernal=(3, 3, 3, 20, 20),
                                image_z=Z,
                                height=H,
                                width=W,
                                phase=phase,
                                drop=drop,
                                scope='decode4_6')
    # layer14->output
    output_map = conv_sigmod(x=decode4,
                             kernal=(1, 1, 1, 20, n_class),
                             scope='output')
    return output_map
示例#9
0
def _create_Nest_net(X,
                     image_z,
                     image_width,
                     image_height,
                     image_channel,
                     phase,
                     drop,
                     n_class=1):
    inputX = tf.reshape(
        X, [-1, image_z, image_width, image_height, image_channel
            ])  # shape=(?, 32, 32, 1)
    # Vnet model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX,
                               kernal=(3, 3, 3, image_channel, 16),
                               phase=phase,
                               drop=drop,
                               scope='layer0')
    layer1 = conv_bn_relu_drop(x=layer0,
                               kernal=(3, 3, 3, 16, 16),
                               phase=phase,
                               drop=drop,
                               scope='layer1')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1,
                          kernal=(3, 3, 3, 16, 32),
                          phase=phase,
                          drop=drop,
                          scope='down1')
    # layer2->convolution
    layer2 = conv_bn_relu_drop(x=down1,
                               kernal=(3, 3, 3, 32, 32),
                               phase=phase,
                               drop=drop,
                               scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2,
                               kernal=(3, 3, 3, 32, 32),
                               phase=phase,
                               drop=drop,
                               scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2,
                          kernal=(3, 3, 3, 32, 64),
                          phase=phase,
                          drop=drop,
                          scope='down2')
    # Nested block1
    deconv1_1 = deconv_relu(x=layer2,
                            kernal=(3, 3, 3, 16, 32),
                            scope='deconv1_1')
    layer1_1 = crop_and_concat(layer1, deconv1_1)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer1_1 = conv_bn_relu_drop(x=layer1_1,
                                 kernal=(3, 3, 3, 32, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_1_1')
    layer1_1 = conv_bn_relu_drop(x=layer1_1,
                                 kernal=(3, 3, 3, 16, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_1_2')
    # layer3->convolution
    layer3 = conv_bn_relu_drop(x=down2,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_2')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 64, 64),
                               phase=phase,
                               drop=drop,
                               scope='layer3_3')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3,
                          kernal=(3, 3, 3, 64, 128),
                          phase=phase,
                          drop=drop,
                          scope='down3')
    # Nested block2
    deconv2_1 = deconv_relu(x=layer3,
                            kernal=(3, 3, 3, 32, 64),
                            scope='deconv2_1')
    layer2_1 = crop_and_concat(layer2, deconv2_1)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer2_1 = conv_bn_relu_drop(x=layer2_1,
                                 kernal=(3, 3, 3, 64, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_1_1')
    layer2_1 = conv_bn_relu_drop(x=layer2_1,
                                 kernal=(3, 3, 3, 32, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_1_2')
    # Nested block3
    deconv1_2 = deconv_relu(x=layer2_1,
                            kernal=(3, 3, 3, 16, 32),
                            scope='deconv1_2')
    layer1_2 = crop_and_concat(layer1_1, deconv1_2)
    layer1_2 = crop_and_concat(layer1_2, layer1)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer1_2 = conv_bn_relu_drop(x=layer1_2,
                                 kernal=(3, 3, 3, 16 * 3, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_2_1')
    layer1_2 = conv_bn_relu_drop(x=layer1_2,
                                 kernal=(3, 3, 3, 16, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_2_2')
    # layer4->convolution
    layer4 = conv_bn_relu_drop(x=down3,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_2')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 128, 128),
                               phase=phase,
                               drop=drop,
                               scope='layer4_3')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4,
                          kernal=(3, 3, 3, 128, 256),
                          phase=phase,
                          drop=drop,
                          scope='down4')
    # Nested block4
    deconv3_1 = deconv_relu(x=layer4,
                            kernal=(3, 3, 3, 64, 128),
                            scope='deconv3_1')
    layer3_1 = crop_and_concat(layer3, deconv3_1)
    _, Z, H, W, _ = layer3.get_shape().as_list()
    layer3_1 = conv_bn_relu_drop(x=layer3_1,
                                 kernal=(3, 3, 3, 128, 64),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer3_1_1')
    layer3_1 = conv_bn_relu_drop(x=layer3_1,
                                 kernal=(3, 3, 3, 64, 64),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer3_1_2')
    # Nested block5
    deconv2_2 = deconv_relu(x=layer3_1,
                            kernal=(3, 3, 3, 32, 64),
                            scope='deconv2_2')
    layer2_2 = crop_and_concat(layer2_1, deconv2_2)
    layer2_2 = crop_and_concat(layer2_2, layer2)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer2_2 = conv_bn_relu_drop(x=layer2_2,
                                 kernal=(3, 3, 3, 32 * 3, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_2_1')
    layer2_2 = conv_bn_relu_drop(x=layer2_2,
                                 kernal=(3, 3, 3, 32, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_2_2')
    # Nested block6
    deconv1_3 = deconv_relu(x=layer2_2,
                            kernal=(3, 3, 3, 16, 32),
                            scope='deconv1_3')
    layer1_3 = crop_and_concat(layer1_2, deconv1_3)
    layer1_3 = crop_and_concat(layer1_3, layer1_1)
    layer1_3 = crop_and_concat(layer1_3, layer1)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer1_3 = conv_bn_relu_drop(x=layer1_3,
                                 kernal=(3, 3, 3, 16 * 4, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_3_1')
    layer1_3 = conv_bn_relu_drop(x=layer1_3,
                                 kernal=(3, 3, 3, 16, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_3_2')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_2')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 256, 256),
                               phase=phase,
                               drop=drop,
                               scope='layer5_3')
    layer5 = resnet_Add(x1=down4, x2=layer5)
    # Nested block7
    deconv4_1 = deconv_relu(x=layer5,
                            kernal=(3, 3, 3, 128, 256),
                            scope='deconv4_1')
    layer4_1 = crop_and_concat(layer4, deconv4_1)
    _, Z, H, W, _ = layer4.get_shape().as_list()
    layer4_1 = conv_bn_relu_drop(x=layer4_1,
                                 kernal=(3, 3, 3, 256, 128),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer4_1_1')
    layer4_1 = conv_bn_relu_drop(x=layer4_1,
                                 kernal=(3, 3, 3, 128, 128),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer4_1_2')
    # Nested block8
    deconv3_2 = deconv_relu(x=layer4_1,
                            kernal=(3, 3, 3, 64, 128),
                            scope='deconv3_2')
    layer3_2 = crop_and_concat(layer3_1, deconv3_2)
    layer3_2 = crop_and_concat(layer3_2, layer3)
    _, Z, H, W, _ = layer3.get_shape().as_list()
    layer3_2 = conv_bn_relu_drop(x=layer3_2,
                                 kernal=(3, 3, 3, 64 * 3, 64),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer3_2_1')
    layer3_2 = conv_bn_relu_drop(x=layer3_2,
                                 kernal=(3, 3, 3, 64, 64),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer3_2_2')
    # Nested block9
    deconv2_3 = deconv_relu(x=layer3_2,
                            kernal=(3, 3, 3, 32, 64),
                            scope='deconv2_3')
    layer2_3 = crop_and_concat(layer2_2, deconv2_3)
    layer2_3 = crop_and_concat(layer2_3, layer2_1)
    layer2_3 = crop_and_concat(layer2_3, layer2)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer2_3 = conv_bn_relu_drop(x=layer2_3,
                                 kernal=(3, 3, 3, 32 * 4, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_3_1')
    layer2_3 = conv_bn_relu_drop(x=layer2_3,
                                 kernal=(3, 3, 3, 32, 32),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer2_3_2')
    # Nested block10
    deconv1_4 = deconv_relu(x=layer2_3,
                            kernal=(3, 3, 3, 16, 32),
                            scope='deconv1_4')
    layer1_4 = crop_and_concat(layer1_3, deconv1_4)
    layer1_4 = crop_and_concat(layer1_4, layer1_2)
    layer1_4 = crop_and_concat(layer1_4, layer1_1)
    layer1_4 = crop_and_concat(layer1_4, layer1)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer1_4 = conv_bn_relu_drop(x=layer1_4,
                                 kernal=(3, 3, 3, 16 * 5, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_4_1')
    layer1_4 = conv_bn_relu_drop(x=layer1_4,
                                 kernal=(3, 3, 3, 16, 16),
                                 phase=phase,
                                 drop=drop,
                                 image_z=Z,
                                 height=H,
                                 width=W,
                                 scope='layer1_4_2')
    # layer14->output
    output_map1 = conv_sigmod(x=layer1_1,
                              kernal=(1, 1, 1, 16, n_class),
                              scope='output1')
    output_map2 = conv_sigmod(x=layer1_2,
                              kernal=(1, 1, 1, 16, n_class),
                              scope='output2')
    output_map3 = conv_sigmod(x=layer1_3,
                              kernal=(1, 1, 1, 16, n_class),
                              scope='output3')
    output_map4 = conv_sigmod(x=layer1_4,
                              kernal=(1, 1, 1, 16, n_class),
                              scope='output4')
    return output_map1, output_map2, output_map3, output_map4
示例#10
0
def _create_peconv_net(X,
                       image_z,
                       image_width,
                       image_height,
                       image_channel,
                       phase,
                       drop,
                       n_class=2):
    inputX = tf.reshape(
        X, [-1, image_z, image_width, image_height, image_channel
            ])  # shape=(?, 32, 32, 1)
    # Vnet model
    # layer1->convolution
    layer0 = conv_bn_relu_drop(x=inputX,
                               kernal=(3, 3, 3, image_channel, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer0')
    layer1 = conv_bn_relu_drop(x=layer0,
                               kernal=(3, 3, 3, 20, 20),
                               phase=phase,
                               drop=drop,
                               scope='layer1')
    layer1 = project_excitation_layer(layer1, out_dim=20, scope='pe1')
    layer1 = resnet_Add(x1=layer0, x2=layer1)
    # down sampling1
    down1 = down_sampling(x=layer1,
                          kernal=(3, 3, 3, 20, 40),
                          phase=phase,
                          drop=drop,
                          scope='down1')
    # layer2->convolution
    layer2 = conv_bn_relu_drop(x=down1,
                               kernal=(3, 3, 3, 40, 40),
                               phase=phase,
                               drop=drop,
                               scope='layer2_1')
    layer2 = conv_bn_relu_drop(x=layer2,
                               kernal=(3, 3, 3, 40, 40),
                               phase=phase,
                               drop=drop,
                               scope='layer2_2')
    layer2 = project_excitation_layer(layer2, out_dim=40, scope='pe2')
    layer2 = resnet_Add(x1=down1, x2=layer2)
    # down sampling2
    down2 = down_sampling(x=layer2,
                          kernal=(3, 3, 3, 40, 80),
                          phase=phase,
                          drop=drop,
                          scope='down2')
    # layer3->convolution
    layer3 = conv_bn_relu_drop(x=down2,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_1')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_2')
    layer3 = conv_bn_relu_drop(x=layer3,
                               kernal=(3, 3, 3, 80, 80),
                               phase=phase,
                               drop=drop,
                               scope='layer3_3')
    layer3 = project_excitation_layer(layer3, out_dim=80, scope='pe3')
    layer3 = resnet_Add(x1=down2, x2=layer3)
    # down sampling3
    down3 = down_sampling(x=layer3,
                          kernal=(3, 3, 3, 80, 160),
                          phase=phase,
                          drop=drop,
                          scope='down3')
    # layer4->convolution
    layer4 = conv_bn_relu_drop(x=down3,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_1')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_2')
    layer4 = conv_bn_relu_drop(x=layer4,
                               kernal=(3, 3, 3, 160, 160),
                               phase=phase,
                               drop=drop,
                               scope='layer4_4')
    layer4 = project_excitation_layer(layer4, out_dim=160, scope='pe4')
    layer4 = resnet_Add(x1=down3, x2=layer4)
    # down sampling4
    down4 = down_sampling(x=layer4,
                          kernal=(3, 3, 3, 160, 320),
                          phase=phase,
                          drop=drop,
                          scope='down4')
    # layer5->convolution
    layer5 = conv_bn_relu_drop(x=down4,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_1')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_2')
    layer5 = conv_bn_relu_drop(x=layer5,
                               kernal=(3, 3, 3, 320, 320),
                               phase=phase,
                               drop=drop,
                               scope='layer5_3')
    layer5 = project_excitation_layer(layer5, out_dim=320, scope='pe5')
    layer5 = resnet_Add(x1=down4, x2=layer5)

    # layer9->deconvolution
    deconv1 = deconv_relu(x=layer5,
                          kernal=(3, 3, 3, 160, 320),
                          scope='deconv1')
    # layer8->convolution
    layer6 = crop_and_concat(layer4, deconv1)
    _, Z, H, W, _ = layer4.get_shape().as_list()
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 320, 160),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_1')
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 160, 160),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_2')
    layer6 = conv_bn_relu_drop(x=layer6,
                               kernal=(3, 3, 3, 160, 160),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer6_3')
    layer6 = project_excitation_layer(layer6,
                                      out_dim=160,
                                      image_z=Z,
                                      height=H,
                                      width=W,
                                      scope='pe6')
    layer6 = resnet_Add(x1=deconv1, x2=layer6)
    # layer9->deconvolution
    deconv2 = deconv_relu(x=layer6, kernal=(3, 3, 3, 80, 160), scope='deconv2')
    # layer8->convolution
    layer7 = crop_and_concat(layer3, deconv2)
    _, Z, H, W, _ = layer3.get_shape().as_list()
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 160, 80),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_1')
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 80, 80),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_2')
    layer7 = conv_bn_relu_drop(x=layer7,
                               kernal=(3, 3, 3, 80, 80),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer7_3')
    layer7 = project_excitation_layer(layer7,
                                      out_dim=80,
                                      image_z=Z,
                                      height=H,
                                      width=W,
                                      scope='pe7')
    layer7 = resnet_Add(x1=deconv2, x2=layer7)
    # layer9->deconvolution
    deconv3 = deconv_relu(x=layer7, kernal=(3, 3, 3, 40, 80), scope='deconv3')
    # layer8->convolution
    layer8 = crop_and_concat(layer2, deconv3)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 80, 40),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_1')
    layer8 = conv_bn_relu_drop(x=layer8,
                               kernal=(3, 3, 3, 40, 40),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer8_2')
    layer8 = project_excitation_layer(layer8,
                                      out_dim=40,
                                      image_z=Z,
                                      height=H,
                                      width=W,
                                      scope='pe8')
    layer8 = resnet_Add(x1=deconv3, x2=layer8)
    # layer9->deconvolution
    deconv4 = deconv_relu(x=layer8, kernal=(3, 3, 3, 20, 40), scope='deconv4')
    # layer8->convolution
    layer9 = crop_and_concat(layer1, deconv4)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 40, 20),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_1')
    layer9 = conv_bn_relu_drop(x=layer9,
                               kernal=(3, 3, 3, 20, 20),
                               image_z=Z,
                               height=H,
                               width=W,
                               phase=phase,
                               drop=drop,
                               scope='layer9_2')
    layer9 = project_excitation_layer(layer9,
                                      out_dim=20,
                                      image_z=Z,
                                      height=H,
                                      width=W,
                                      scope='pe9')
    layer9 = resnet_Add(x1=deconv4, x2=layer9)
    # layer14->output
    output_map = conv_sigomd(x=layer9,
                             kernal=(1, 1, 1, 20, n_class),
                             scope='output')

    return output_map
示例#11
0
文件: model_resnet.py 项目: KDV5/LiTS
def _create_conv_net(X, image_depth, image_height, image_width, image_channel,
                     inner_channel, phase, drop):
    inputX = tf.reshape(
        X, [-1, image_depth, image_width, image_height, image_channel
            ])  # shape=(?, 256, 256, 1)
    # ResUnet model
    # Res-block0
    layer0_0 = conv_bn_relu_drop(x=inputX,
                                 kernel=(3, 3, 3, image_channel,
                                         inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer0_0')
    layer0_1 = conv_bn_relu_drop(x=layer0_0,
                                 kernel=(3, 3, 3, inner_channel,
                                         inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer0_1')
    layer0_2 = conv_bn_relu_drop(x=layer0_0,
                                 kernel=(3, 3, 3, inner_channel,
                                         inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer0_2')
    layer0 = resnet_Add(x1=layer0_1, x2=layer0_2)
    # down sampling
    down0 = down_sampling(x=layer0,
                          kernel=(3, 3, 3, inner_channel, 2 * inner_channel),
                          phase=phase,
                          drop=drop,
                          scope='down0')

    # Res-block1
    layer1_1 = conv_bn_relu_drop(x=down0,
                                 kernel=(3, 3, 3, 2 * inner_channel,
                                         2 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer1_1')
    layer1_2 = conv_bn_relu_drop(x=layer1_1,
                                 kernel=(3, 3, 3, 2 * inner_channel,
                                         2 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer1_2')
    layer1 = resnet_Add(x1=down0, x2=layer1_2)
    # down sampling
    down1 = down_sampling(x=layer1,
                          kernel=(3, 3, 3, 2 * inner_channel,
                                  4 * inner_channel),
                          phase=phase,
                          drop=drop,
                          scope='down1')

    # Res-block2
    layer2_1 = conv_bn_relu_drop(x=down1,
                                 kernel=(3, 3, 3, 4 * inner_channel,
                                         4 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer2_1')
    layer2_2 = conv_bn_relu_drop(x=layer2_1,
                                 kernel=(3, 3, 3, 4 * inner_channel,
                                         4 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer2_2')
    layer2 = resnet_Add(x1=down1, x2=layer2_2)
    # down sampling
    down2 = down_sampling(x=layer2,
                          kernel=(3, 3, 3, 4 * inner_channel,
                                  8 * inner_channel),
                          phase=phase,
                          drop=drop,
                          scope='down2')

    # Res-block3
    layer3_1 = conv_bn_relu_drop(x=down2,
                                 kernel=(3, 3, 3, 8 * inner_channel,
                                         8 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer3_1')
    layer3_2 = conv_bn_relu_drop(x=layer3_1,
                                 kernel=(3, 3, 3, 8 * inner_channel,
                                         8 * inner_channel),
                                 phase=phase,
                                 drop=drop,
                                 scope='layer3_2')
    layer3 = resnet_Add(x1=down2, x2=layer3_2)

    # up sampling
    up2 = deconv_relu(x=layer3,
                      kernel=(3, 3, 3, 4 * inner_channel, 8 * inner_channel),
                      scope='up3')
    # Res-block4
    concat0 = crop_and_concat(layer2, up2)
    _, Z, H, W, _ = layer2.get_shape().as_list()
    layer4_1 = conv_bn_relu_drop(x=concat0,
                                 kernel=(3, 3, 3, 8 * inner_channel,
                                         4 * inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_1')
    layer4_2 = conv_bn_relu_drop(x=layer4_1,
                                 kernel=(3, 3, 3, 4 * inner_channel,
                                         4 * inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_2')
    layer4 = resnet_Add(x1=up2, x2=layer4_2)

    # up sampling
    up1 = deconv_relu(x=layer4,
                      kernel=(3, 3, 3, 2 * inner_channel, 4 * inner_channel),
                      scope='up3')
    # Res-block5
    concat1 = crop_and_concat(layer1, up1)
    _, Z, H, W, _ = layer1.get_shape().as_list()
    layer5_1 = conv_bn_relu_drop(x=concat1,
                                 kernel=(3, 3, 3, 4 * inner_channel,
                                         2 * inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_1')
    layer5_2 = conv_bn_relu_drop(x=layer5_1,
                                 kernel=(3, 3, 3, 2 * inner_channel,
                                         2 * inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_2')
    layer5 = resnet_Add(x1=up1, x2=layer5_2)

    # up sampling
    up0 = deconv_relu(x=layer5,
                      kernel=(3, 3, 3, inner_channel, 2 * inner_channel),
                      scope='up3')
    # Res-block6
    concat2 = crop_and_concat(layer0, up0)
    _, Z, H, W, _ = layer0.get_shape().as_list()
    layer6_1 = conv_bn_relu_drop(x=concat2,
                                 kernel=(3, 3, 3, 2 * inner_channel,
                                         inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_1')
    layer6_2 = conv_bn_relu_drop(x=layer6_1,
                                 kernel=(3, 3, 3, inner_channel,
                                         inner_channel),
                                 depth=Z,
                                 height=H,
                                 width=W,
                                 phase=phase,
                                 drop=drop,
                                 scope='layer4_2')
    layer6 = resnet_Add(x1=up0, x2=layer6_2)

    output = conv_output(layer6,
                         kernel=(3, 3, 3, inner_channel, 1),
                         scope='output')
    return output