Пример #1
0
    def __init__(self, name, bn=False, ln=False, act=tf.nn.leaky_relu):

        # stage 1
        self.st1_1 = Conv2DLayer(64, 3, 1, '{}_st1_1'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st1_2 = Conv2DLayer(64, 3, 1, '{}_st1_2'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        # stage 2
        self.st2_1 = Conv2DLayer(128, 3, 1, '{}_st2_1'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st2_2 = Conv2DLayer(128, 3, 1, '{}_st2_2'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        # stage 3
        self.st3_1 = Conv2DLayer(256, 3, 1, '{}_st3_1'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st3_2 = Conv2DLayer(256, 3, 1, '{}_st3_2'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st3_3 = Conv2DLayer(256, 3, 1, '{}_st3_3'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        # stage 4
        self.st4_1 = Conv2DLayer(512, 3, 1, '{}_st4_1'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st4_2 = Conv2DLayer(512, 3, 1, '{}_st4_2'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st4_3 = Conv2DLayer(512, 3, 1, '{}_st4_3'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        # stage 5
        self.st5_1 = Conv2DLayer(512, 3, 1, '{}_st5_1'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st5_2 = Conv2DLayer(512, 3, 1, '{}_st5_2'.format(name), 0.0, bn,
                                 ln, "SAME", act)

        self.st5_3 = Conv2DLayer(512, 3, 1, '{}_st5_3'.format(name), 0.0, bn,
                                 ln, "SAME", act)
Пример #2
0
    def __init__(self,
                 name,
                 dropout=0.0,
                 bn=False,
                 ln=False,
                 padding="SAME",
                 act=tf.nn.leaky_relu):

        self.act = act

        #===========ENTRY FLOW==============
        # block1
        self.b1c1 = Conv2DLayer(32, 3, 2, '{}_block1_conv1'.format(name),
                                dropout, bn, ln, "VALID", act)
        self.b1c2 = Conv2DLayer(64, 3, 1, '{}_block1_conv2'.format(name),
                                dropout, bn, ln, "VALID", act)
        self.b1r1 = Conv2DLayer(128, 1, 2, '{}_block1_res_conv'.format(name),
                                dropout, bn, ln, padding, None)

        # block2
        self.b2c1 = SeparableConv2DLayer(128, 3, 1,
                                         '{}_block2_dws_conv1'.format(name),
                                         dropout, bn, ln, padding, act)
        self.b2c2 = SeparableConv2DLayer(128, 3, 1,
                                         '{}_block2_dws_conv2'.format(name),
                                         dropout, bn, ln, padding, None)
        self.b2r1 = Conv2DLayer(256, 1, 2, '{}_block2_res_conv'.format(name),
                                dropout, bn, ln, padding, None)

        # block3
        self.b3c1 = SeparableConv2DLayer(256, 3, 1,
                                         '{}_block3_dws_conv1'.format(name),
                                         dropout, bn, ln, padding, act)
        self.b3c2 = SeparableConv2DLayer(256, 3, 1,
                                         '{}_block3_dws_conv2'.format(name),
                                         dropout, bn, ln, padding, None)
        self.b3r1 = Conv2DLayer(728, 1, 2, '{}_block3_res_conv'.format(name),
                                dropout, bn, ln, padding, None)

        # block4
        self.b4c1 = SeparableConv2DLayer(728, 3, 1,
                                         '{}_block4_dws_conv1'.format(name),
                                         dropout, bn, ln, padding, act)
        self.b4c2 = SeparableConv2DLayer(728, 3, 1,
                                         '{}_block4_dws_conv2'.format(name),
                                         dropout, bn, ln, padding, act)

        #===========MIDDLE FLOW===============
        self.block = []
        for i in range(8):
            block_prefix = 'block%s_' % (str(i + 5))
            self.block.append([
                SeparableConv2DLayer(
                    728, 3, 1,
                    '{}_block_{}_dws_conv1'.format(name, block_prefix),
                    dropout, bn, ln, padding, act),
                SeparableConv2DLayer(
                    728, 3, 1,
                    '{}_block_{}_dws_conv2'.format(name, block_prefix),
                    dropout, bn, ln, padding, act),
                SeparableConv2DLayer(
                    728, 3, 1,
                    '{}_block_{}_dws_conv3'.format(name, block_prefix),
                    dropout, bn, ln, padding, None)
            ])

        #========EXIT FLOW============
        self.er0 = Conv2DLayer(1024, 1, 2, '{}_block12_res_conv'.format(name),
                               dropout, bn, ln, padding, None)

        self.ec0 = SeparableConv2DLayer(728, 3, 1,
                                        '{}_block13_dws_conv1'.format(name),
                                        dropout, bn, ln, padding, act)
        self.ec1 = SeparableConv2DLayer(1024, 3, 1,
                                        '{}_block13_dws_conv2'.format(name),
                                        dropout, bn, ln, padding, None)

        self.ec2 = SeparableConv2DLayer(1536, 3, 1,
                                        '{}_block14_dws_conv1'.format(name),
                                        dropout, bn, ln, padding, act)
        self.ec3 = SeparableConv2DLayer(2048, 3, 1,
                                        '{}_block14_dws_conv2'.format(name),
                                        dropout, bn, ln, padding, act)
Пример #3
0
    def __init__( self,
                  name,
                  dropout = 0.0, bn = False, ln = False,
                  act = tf.nn.leaky_relu):

        self.name = name
                
        self.c1 = Conv2DLayer( 32, 3, 2, '{}_incep_resnet_stem_0'.format( name ), 
                               dropout, bn, ln, "SAME", act )
        self.c2 = Conv2DLayer( 32, 3, 1, '{}_incep_resnet_stem_1'.format( name ),
                               dropout, bn, ln, "SAME", act )
        self.c3 = Conv2DLayer( 64, 3, 1, '{}_incep_resnet_stem_2'.format( name ),
                               dropout, bn, ln, "SAME", act )

        self.c4 = Conv2DLayer( 96, 3, 2, '{}_incep_resnet_stem_4'.format( name ),
                               dropout, bn, ln, "SAME", act )

        self.c5_0 = Conv2DLayer( 64, 1, 1, '{}_incep_resnet_stem_5_0'.format( name ),
                               dropout, bn, ln, "SAME", act )
        self.c5_1 = Conv2DLayer( 64, (1,7), 1, '{}_incep_resnet_stem_5_1'.format( name ),
                               dropout, bn, ln, "SAME", act )
        self.c5_2 = Conv2DLayer( 64, (7,1), 1, '{}_incep_resnet_stem_5_2'.format( name ),
                               dropout, bn, ln, "SAME", act )
        self.c5_3 = Conv2DLayer( 96, 3, 1, '{}_incep_resnet_stem_5_3'.format( name ),
                               dropout, bn, ln, "SAME", act )

        self.c6_0 = Conv2DLayer( 64, 1, 1, '{}_incep_resnet_stem_6_0'.format( name ),
                               dropout, bn, ln, "SAME", act )
        self.c6_1 = Conv2DLayer( 96, 3, 1, '{}_incep_resnet_stem_6_1'.format( name ),
                               dropout, bn, ln, "SAME", act )

        self.c7 = Conv2DLayer( 192, 3, 2, '{}_incep_resnet_stem_7'.format( name ),
                               dropout, bn, ln, "SAME", act )                           
Пример #4
0
    def __init__( self,
                  name, scope,
                  chanels,
                  dropout = 0.0, bn = False,
                  padding = "SAME",  
                  act = tf.nn.leaky_relu ):

        self.act = act

        # downsample
        self.c0_0 = Conv2DLayer( 64, 3, 1,  "{}_c00".format( name ), bn = bn, ln = ln, act = act )

        self.c1_0 = Conv2DLayer( 64,  3, 1, "{}_c10".format( name ), bn = bn, ln = ln, act = act )
        self.c1_1 = Conv2DLayer( 128, 3, 1, "{}_c11".format( name ), bn = bn, ln = ln, act = act )

        self.c2_0 = Conv2DLayer( 128, 3, 1, "{}_c20".format( name ), bn = bn, ln = ln, act = act )
        self.c2_1 = Conv2DLayer( 256, 3, 1, "{}_c21".format( name ), bn = bn, ln = ln, act = act )
        self.c2_2 = Conv2DLayer( 256, 3, 1, "{}_c22".format( name ), bn = bn, ln = ln, act = act )

        self.c3_0 = Conv2DLayer( 256, 3, 1, "{}_c30".format( name ), bn = bn, ln = ln, act = act )
        self.c3_1 = Conv2DLayer( 512, 3, 1, "{}_c31".format( name ), bn = bn, ln = ln, act = act )
        self.c3_2 = Conv2DLayer( 512, 3, 1, "{}_c32".format( name ), bn = bn, ln = ln, act = act )

        self.c4_0 = Conv2DLayer( 512, 3, 1, "{}_c40".format( name ), bn = bn, ln = ln, act = act )
        self.c4_1 = Conv2DLayer( 512, 3, 1, "{}_c41".format( name ), bn = bn, ln = ln, act = act )
        self.c4_2 = Conv2DLayer( 512, 3, 1, "{}_c42".format( name ), bn = bn, ln = ln, act = act )

        self.c5_0 = Conv2DLayer( 512, 3, 1, "{}_c50".format( name ), bn = bn, ln = ln, act = act )
        self.c5_1 = Conv2DLayer( 512, 3, 1, "{}_c51".format( name ), bn = bn, ln = ln, act = act )
        
        # upsample
        self.d0_0 = Deconv2DLayer( 256, 2, 2, "{}_d00".format( name ), bn = bn, ln = ln, act = act )
        self.d0_1 = Deconv2DLayer( 512, 3, 1, "{}_d01".format( name ), bn = bn, ln = ln, act = act )

        self.d1_0 = Deconv2DLayer( 256, 2, 2, "{}_d10".format( name ), bn = bn, ln = ln, act = act )
        self.d1_1 = Deconv2DLayer( 512, 3, 1, "{}_d11".format( name ), bn = bn, ln = ln, act = act )

        self.d2_0 = Deconv2DLayer( 128, 2, 2, "{}_d20".format( name ), bn = bn, ln = ln, act = act )
        self.d2_1 = Deconv2DLayer( 256, 3, 1, "{}_d21".format( name ), bn = bn, ln = ln, act = act )

        self.d3_0 = Deconv2DLayer( 64,  2, 2, "{}_d30".format( name ), bn = bn, ln = ln, act = act )
        self.d3_1 = Deconv2DLayer( 128, 3, 1, "{}_d31".format( name ), bn = bn, ln = ln, act = act )

        self.d4_0 = Deconv2DLayer( 32, 2, 2,  "{}_d40".format( name ), bn = bn, ln = ln, act = act )
        self.d4_1 = Deconv2DLayer( chanels, 3,  1,  "{}_d41".format( name ), bn = False, act = tf.nn.sigmoid )