Example #1
0
def stem_1(name , x ):
    with tf.variable_scope(name) as scope:
        layer = convolution2d('cnn_0', x, 64, k=1, s=1)
        layer = convolution2d('cnn_1', layer, 96, k=3, s=1, padding='VALID')
        layer_ = convolution2d('cnn__0', x, 64, k=1, s=1)
        layer_ = convolution2d_manual('cnn__1', layer_, 64, k_h=7,k_w=1, s=1)
        layer_ = convolution2d_manual('cnn__2', layer_, 64, k_h=1,k_w=7,s=1 )
        layer_ = convolution2d('cnn__3', layer_, 96, k=3, s=1, padding='VALID')

        layer_join = tf.concat([layer, layer_], axis=3, name='join')
        print 'layer_name :','join'
        print 'layer_shape :',layer_join.get_shape()
    return layer_join
Example #2
0
def resnet_blockC(name, x):
    with tf.variable_scope(name) as scope:
        layer = convolution2d('cnn0', x, 192, 1, 1)
        layer_ = convolution2d('cnn_0', x, 192, 1, 1)
        layer_ = convolution2d_manual('cnn_1', layer_, 192, k_h=1, k_w=3, s=1)
        layer_ = convolution2d_manual('cnn_2', layer_, 192, k_h=3, k_w=1, s=1)
        layer_join = tf.concat([layer, layer_], axis=3, name='join')
        layer_join = convolution2d('layer_join_cnn', layer_join, 1792, 1, 1)
        if x.get_shape()[-1] != layer_join.get_shape()[-1]:
            x=convolution2d('upscale_dimension',x, layer_join.get_shape()[-1] , k=1,s=1)
        layer_join = tf.add(x, layer_join, 'add')
        print 'layer_name :', 'join'
        print 'layer_shape :', layer_join.get_shape()
        return layer_join
Example #3
0
def reductionB(name , x):
    with tf.variable_scope(name) as scope:
        layer_ = max_pool('max_pool_0',x, k=3, s=2, padding='VALID')

        layer__ = convolution2d('cnn__0',x,192, k=1, s=1, padding='SAME')
        layer__ = convolution2d('cnn__1' ,layer__, 192,k=3 ,s=2 ,padding='VALID')

        layer___ = convolution2d('cnn___0',x,256, k=1, s=1, padding='SAME')
        layer___ = convolution2d_manual('cnn___1',layer___,256, k_h=1 , k_w=7, s=1, padding='SAME')
        layer___ = convolution2d_manual('cnn___2',layer___,320, k_h=7, k_w=1, s=1, padding='SAME')
        layer___ = convolution2d('cnn___3',layer___, 320,k=3, s=2, padding='VALID')

        layer_join=tf.concat([layer_ , layer__ , layer___] , axis=3 , name='join')
        print 'layer_name :','join'
        print 'layer_shape :',layer_join.get_shape()
    return layer_join
def blockC(name, x):
    with tf.variable_scope(name) as scope:
        layer = avg_pool('avg_pool', x, k=2, s=1)
        layer = convolution2d('cnn', layer, 256, k=1, s=1)

        layer_ = convolution2d('cnn_0', x, 256, k=1, s=1)

        layer__ = convolution2d('cnn__0', x, 384, k=1, s=1)
        layer__0 = convolution2d_manual('cnn__1_0',
                                        layer__,
                                        256,
                                        k_h=1,
                                        k_w=3,
                                        s=1)
        layer__1 = convolution2d_manual('cnn__1_1',
                                        layer__,
                                        256,
                                        k_h=3,
                                        k_w=1,
                                        s=1)

        layer___ = convolution2d('cnn___0', x, 384, k=1, s=1)
        layer___ = convolution2d_manual('cnn___1',
                                        layer___,
                                        448,
                                        k_h=1,
                                        k_w=3,
                                        s=1)
        layer___ = convolution2d_manual('cnn___2',
                                        layer___,
                                        512,
                                        k_h=3,
                                        k_w=1,
                                        s=1)
        layer___0 = convolution2d_manual('cnn___3_0',
                                         layer___,
                                         256,
                                         k_h=3,
                                         k_w=1,
                                         s=1)
        layer___1 = convolution2d_manual('cnn___3_1',
                                         layer___,
                                         256,
                                         k_h=1,
                                         k_w=3,
                                         s=1)
        layer_join = tf.concat(
            [layer, layer_, layer__0, layer__1, layer___0, layer___1],
            axis=3,
            name='join')
        print 'layer_name :', 'join'
        print 'layer_shape :', layer_join.get_shape()
        return layer_join
def blockB(name, x):
    with tf.variable_scope(name) as scope:
        layer = avg_pool('avg_pool', x, k=2, s=1)
        layer = convolution2d('cnn', layer, 128, k=1, s=1)

        layer_ = convolution2d('cnn_0', x, 384, k=1, s=1)

        layer__ = convolution2d('cnn__0', x, 192, k=1, s=1)
        layer__ = convolution2d_manual('cnn__1',
                                       layer__,
                                       224,
                                       k_h=1,
                                       k_w=7,
                                       s=1)
        layer__ = convolution2d_manual('cnn__2',
                                       layer__,
                                       256,
                                       k_h=1,
                                       k_w=7,
                                       s=1)

        layer___ = convolution2d('cnn___0', x, 192, k=1, s=1)
        layer___ = convolution2d_manual('cnn___1',
                                        layer___,
                                        192,
                                        k_h=1,
                                        k_w=7,
                                        s=1)
        layer___ = convolution2d_manual('cnn___2',
                                        layer___,
                                        224,
                                        k_h=7,
                                        k_w=1,
                                        s=1)
        layer___ = convolution2d_manual('cnn___3',
                                        layer___,
                                        224,
                                        k_h=1,
                                        k_w=7,
                                        s=1)
        layer___ = convolution2d_manual('cnn___4',
                                        layer___,
                                        256,
                                        k_h=7,
                                        k_w=1,
                                        s=1)

        layer_join = tf.concat([layer, layer_, layer__, layer___],
                               axis=3,
                               name='join')
        print 'layer_name :', 'join'
        print 'layer_shape :', layer_join.get_shape()
    return layer_join