Ejemplo n.º 1
0
def model_core_squeezenet17(x, mode, params, info):
    y, info = layer.conv2d_batch_norm_relu_dropout_l(x, mode, params, info, filters=128, kernel_size=3, strides=1)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*64)
    y, info = layer.maxpool_l(y, info)  # output 128x128
    #y, info = layer.sqnet_squeeze_pool(y, mode, params, info, 80)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 80)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*96)
    y, info = layer.maxpool_l(y, info)  # output 64x64
    #y, info = layer.sqnet_squeeze_pool(y, mode, params, info, 104)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 104)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*112)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 120)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*128)
    y, info = layer.maxpool_l(y, info)  # output 32x32
    #y, info = layer.sqnet_squeeze_pool(y, mode, params, info, 120)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 120)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*112)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 104)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*96)
    y, info = layer.maxpool_l(y, info)  # output 16x16
    #y, info = layer.sqnet_squeeze_pool(y, mode, params, info, 88)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 88)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*80)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 72)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*65, last=True)
    return y, info
Ejemplo n.º 2
0
def model_core_squeezenet12(x, mode, params, info):
    y, info = layer.conv2d_batch_norm_relu_dropout_l(x, mode, params, info, filters=32, kernel_size=6, strides=2)  # output 128x128
    y, info = layer.maxpool_l(y, info)  # output 64x64
    y, info = layer.sqnet_squeeze(y, mode, params, info, 21)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*26)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 36)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*46)
    y, info = layer.maxpool_l(y, info)  # output 32x32
    y, info = layer.sqnet_squeeze(y, mode, params, info, 41)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*36)
    y, info = layer.sqnet_squeeze(y, mode, params, info, 31)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*26)
    y, info = layer.maxpool_l(y, info)  # output 16x16
    y, info = layer.sqnet_squeeze(y, mode, params, info, 21)
    y, info = layer.sqnet_expand(y, mode, params, info, 2*16, last=True)
    return y, info
Ejemplo n.º 3
0
 def sqnet_squeeze_expand(x, mode, params, info, depth_increment, last=False):
     """Squeezenet "fire" module, i.e. a "squeeze" module followed by an "expand" module."""
     depth = int(x.get_shape()[3])//2
     depth += depth_increment
     x, info = layer.sqnet_squeeze(x, mode, params, info, depth)
     depth += depth_increment
     x, info = layer.sqnet_expand(x, mode, params, info, 2*depth, last=last)
     return x, info
Ejemplo n.º 4
0
def model_core_configurable_squeezenet(x, mode, params, info):
    """This configurable model tries to spread the layers evenly between the maxpool layers
    and also spread depth increases and decreases in a progressive way. Depth at the end is
    the same as it was initially."""
    nlayers = params["layers"]
    depth_increment = params["depth_increment"]
    first_layer_fdepth = params["first_layer_filter_depth"]
    first_layer_fstride = params["first_layer_filter_stride"]
    first_layer_fsize = params["first_layer_filter_size"]
    layers_n, first_expand_layer, depth_incr_doubler = layer.sqnet_spread_layers(nlayers)


    def sqnet_squeeze_expand(x, mode, params, info, depth_increment, last=False):
        """Squeezenet "fire" module, i.e. a "squeeze" module followed by an "expand" module."""
        depth = int(x.get_shape()[3])//2
        depth += depth_increment
        x, info = layer.sqnet_squeeze(x, mode, params, info, depth)
        depth += depth_increment
        x, info = layer.sqnet_expand(x, mode, params, info, 2*depth, last=last)
        return x, info

    y, info = layer.conv2d_batch_norm_relu_dropout_l(x, mode, params, info,
                                                     filters=first_layer_fdepth,
                                                     kernel_size=first_layer_fsize,
                                                     strides=first_layer_fstride)
    if first_expand_layer == 1:
        y, info = layer.sqnet_expand(y, mode, params, info, first_layer_fdepth)
    y, info = layer.maxpool_l(y, info)
    for _ in range(layers_n[1]//2):
        y, info = sqnet_squeeze_expand(y, mode, params, info, depth_increment*depth_incr_doubler[0])
    if first_layer_fstride == 1:
        y, info = layer.maxpool_l(y, info)
    for _ in range(layers_n[2]//2):
        y, info = sqnet_squeeze_expand(y, mode, params, info, depth_increment*depth_incr_doubler[1])
    y, info = layer.maxpool_l(y, info)
    for _ in range(layers_n[3]//2):
        y, info = sqnet_squeeze_expand(y, mode, params, info, -depth_increment*depth_incr_doubler[2])
    y, info = layer.maxpool_l(y, info)
    for i in range(layers_n[4]//2, 0, -1):
        y, info = sqnet_squeeze_expand(y, mode, params, info, -depth_increment*depth_incr_doubler[3], last=(i==1))

    return y, info