您当前的位置:首页 > IT编程 > Keras
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:Python layers.AveragePooling2D方法代码示例

51自学网 2020-12-01 11:08:53
  Keras
这篇教程Python layers.AveragePooling2D方法代码示例写得很实用,希望能帮到您。

本文整理汇总了Python中keras.layers.AveragePooling2D方法的典型用法代码示例。如果您正苦于以下问题:Python layers.AveragePooling2D方法的具体用法?Python layers.AveragePooling2D怎么用?Python layers.AveragePooling2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块keras.layers的用法示例。

在下文中一共展示了layers.AveragePooling2D方法的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: d_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def d_block(inp, fil, p = True):    skip = Conv2D(fil, 1, padding = 'same', kernel_initializer = 'he_normal')(inp)    out = Conv2D(filters = fil, kernel_size = 3, padding = 'same', kernel_initializer = 'he_normal')(inp)    out = LeakyReLU(0.2)(out)    out = Conv2D(filters = fil, kernel_size = 3, padding = 'same', kernel_initializer = 'he_normal')(out)    out = LeakyReLU(0.2)(out)    out = Conv2D(fil, 1, padding = 'same', kernel_initializer = 'he_normal')(out)    out = add([out, skip])    out = LeakyReLU(0.2)(out)    if p:        out = AveragePooling2D()(out)    return out 
开发者ID:manicman1999,项目名称:Keras-BiGAN,代码行数:21,代码来源:bigan.py


示例2: avg_pool2d

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def avg_pool2d(h_kernel_size, h_stride):    def compile_fn(di, dh):        layer = layers.AveragePooling2D(pool_size=dh['kernel_size'],                                        strides=(dh['stride'], dh['stride']),                                        padding='same')        def fn(di):            return {'out': layer(di['in'])}        return fn    return siso_keras_module('AvgPool', compile_fn, {        'kernel_size': h_kernel_size,        'stride': h_stride,    }) 
开发者ID:negrinho,项目名称:deep_architect,代码行数:18,代码来源:keras_ops.py


示例3: add_new_last_layer

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def add_new_last_layer(base_model, nb_classes):    """Add last layer to the convnet        Args:        base_model: keras model excluding top        nb_classes: # of classes            Returns:        new keras model with last layer    """    x = base_model.output    x = AveragePooling2D((8, 8), border_mode='valid', name='avg_pool')(x)    x = Dropout(0.4)(x)    x = Flatten()(x)    predictions = Dense(2, activation='softmax')(x)    model = Model(input=base_model.input, output=predictions)    return model 
开发者ID:DhavalThkkar,项目名称:Transfer-Learning,代码行数:19,代码来源:transfer.py


示例4: transition_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def transition_block(x, reduction, name):    """A transition block.    # Arguments        x: input tensor.        reduction: float, compression rate at transition layers.        name: string, block label.    # Returns        output tensor for the block.    """    bn_axis = 3 if K.image_data_format() == 'channels_last' else 1    x = BatchNormalization(axis=bn_axis, epsilon=1.001e-5,                           name=name + '_bn')(x)    x = Activation('relu', name=name + '_relu')(x)    x = Conv2D(int(K.int_shape(x)[bn_axis] * reduction), 1, use_bias=False,               name=name + '_conv')(x)    x = AveragePooling2D(2, strides=2, name=name + '_pool')(x)    return x 
开发者ID:i-pan,项目名称:kaggle-rsna18,代码行数:21,代码来源:densenet_gray.py


示例5: transition_layer

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def transition_layer(input_tensor, numFilters, compressionFactor=1.0):    numOutPutFilters = int(numFilters*compressionFactor)    if K.image_data_format() == 'channels_last':        bn_axis = -1    else:        bn_axis = 1    x = BatchNormalization(axis=bn_axis)(input_tensor)    x = Activation('relu')(x)    x = Conv2D(numOutPutFilters, (1, 1), strides=(1, 1), padding='same', kernel_initializer='he_normal')(x)    # downsampling    x = AveragePooling2D((2, 2), strides=(2, 2), padding='valid', data_format='channels_last', name='')(x)    return x, numOutPutFilters 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:20,代码来源:densely_connected_cnn_blocks.py


示例6: transition_SE_layer

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def transition_SE_layer(input_tensor, numFilters, compressionFactor=1.0, se_ratio=16):    numOutPutFilters = int(numFilters*compressionFactor)    if K.image_data_format() == 'channels_last':        bn_axis = -1    else:        bn_axis = 1    x = BatchNormalization(axis=bn_axis)(input_tensor)    x = Activation('relu')(x)    x = Conv2D(numOutPutFilters, (1, 1), strides=(1, 1), padding='same', kernel_initializer='he_normal')(x)    # SE Block    x = squeeze_excitation_block(x, ratio=se_ratio)    #x = BatchNormalization(axis=bn_axis)(x)    # downsampling    x = AveragePooling2D((2, 2), strides=(2, 2), padding='valid', data_format='channels_last', name='')(x)    #x = squeeze_excitation_block(x, ratio=se_ratio)    return x, numOutPutFilters 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:26,代码来源:densely_connected_cnn_blocks.py


示例7: model_base_test_CNN

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def model_base_test_CNN(input_shape):    model = Sequential()    model.add(Conv2D(32, (3, 3), input_shape=input_shape, padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(64, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(64, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(128, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(3, 3), strides=(2, 2), padding='same'))    model.add(Flatten())    return model.input, model.output# 64x3 model 
开发者ID:Sentdex,项目名称:Carla-RL,代码行数:26,代码来源:models.py


示例8: model_base_64x3_CNN

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def model_base_64x3_CNN(input_shape):    model = Sequential()    model.add(Conv2D(64, (3, 3), input_shape=input_shape, padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(64, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(64, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Flatten())    return model.input, model.output# 4 CNN layer model 
开发者ID:Sentdex,项目名称:Carla-RL,代码行数:22,代码来源:models.py


示例9: model_base_4_CNN

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def model_base_4_CNN(input_shape):    model = Sequential()    model.add(Conv2D(64, (5, 5), input_shape=input_shape, padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(64, (5, 5), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(5, 5), strides=(3, 3), padding='same'))    model.add(Conv2D(128, (5, 5), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(3, 3), strides=(2, 2), padding='same'))    model.add(Conv2D(256, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(AveragePooling2D(pool_size=(3, 3), strides=(2, 2), padding='same'))    model.add(Flatten())    return model.input, model.output# 5 CNN layer with residual connections model 
开发者ID:Sentdex,项目名称:Carla-RL,代码行数:26,代码来源:models.py


示例10: One_vs_One_Inception

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def One_vs_One_Inception(self, nOutput=2, input=[224, 224, 3]):        """            Builds a simple One_vs_One_Inception network with 2 inception layers (useful for ECOC models).        """        if len(input) == 3:            input_shape = tuple([input[2]] + input[0:2])        else:            input_shape = tuple(input)        self.model = Graph()        # Input        self.model.add_input(name='input', input_shape=input_shape)        # Inception Ea        out_Ea = self.__addInception('inceptionEa', 'input', 4, 2, 8, 2, 2, 2)        # Inception Eb        out_Eb = self.__addInception('inceptionEb', out_Ea, 2, 2, 4, 2, 1, 1)        # Average Pooling    pool_size=(7,7)        self.model.add_node(AveragePooling2D(pool_size=input_shape[1:], strides=(1, 1)), name='ave_pool/ECOC',                            input=out_Eb)        # Softmax        self.model.add_node(Flatten(), name='loss_OnevsOne/classifier_flatten', input='ave_pool/ECOC')        self.model.add_node(Dropout(0.5), name='loss_OnevsOne/drop', input='loss_OnevsOne/classifier_flatten')        self.model.add_node(Dense(nOutput, activation='softmax'), name='loss_OnevsOne', input='loss_OnevsOne/drop')        # Output        self.model.add_output(name='loss_OnevsOne/output', input='loss_OnevsOne') 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:27,代码来源:cnn_model-predictor.py


示例11: add_One_vs_One_Inception

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def add_One_vs_One_Inception(self, input, input_shape, id_branch, nOutput=2, activation='softmax'):        """            Builds a simple One_vs_One_Inception network with 2 inception layers on the top of the current model (useful for ECOC_loss models).        """        # Inception Ea        out_Ea = self.__addInception('inceptionEa_' + str(id_branch), input, 4, 2, 8, 2, 2, 2)        # Inception Eb        out_Eb = self.__addInception('inceptionEb_' + str(id_branch), out_Ea, 2, 2, 4, 2, 1, 1)        # Average Pooling    pool_size=(7,7)        self.model.add_node(AveragePooling2D(pool_size=input_shape[1:], strides=(1, 1)),                            name='ave_pool/ECOC_' + str(id_branch), input=out_Eb)        # Softmax        self.model.add_node(Flatten(),                            name='fc_OnevsOne_' + str(id_branch) + '/flatten', input='ave_pool/ECOC_' + str(id_branch))        self.model.add_node(Dropout(0.5),                            name='fc_OnevsOne_' + str(id_branch) + '/drop',                            input='fc_OnevsOne_' + str(id_branch) + '/flatten')        output_name = 'fc_OnevsOne_' + str(id_branch)        self.model.add_node(Dense(nOutput, activation=activation),                            name=output_name, input='fc_OnevsOne_' + str(id_branch) + '/drop')        return output_name 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:25,代码来源:cnn_model-predictor.py


示例12: add_One_vs_One_Inception_Functional

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def add_One_vs_One_Inception_Functional(self, input, input_shape, id_branch, nOutput=2, activation='softmax'):        """            Builds a simple One_vs_One_Inception network with 2 inception layers on the top of the current model (useful for ECOC_loss models).        """        in_node = self.model.get_layer(input).output        # Inception Ea        [out_Ea, out_Ea_name] = self.__addInception_Functional('inceptionEa_' + str(id_branch), in_node, 4, 2, 8, 2, 2,                                                               2)        # Inception Eb        [out_Eb, out_Eb_name] = self.__addInception_Functional('inceptionEb_' + str(id_branch), out_Ea, 2, 2, 4, 2, 1,                                                               1)        # Average Pooling    pool_size=(7,7)        x = AveragePooling2D(pool_size=input_shape, strides=(1, 1), name='ave_pool/ECOC_' + str(id_branch))(out_Eb)        # Softmax        output_name = 'fc_OnevsOne_' + str(id_branch)        x = Flatten(name='fc_OnevsOne_' + str(id_branch) + '/flatten')(x)        x = Dropout(0.5, name='fc_OnevsOne_' + str(id_branch) + '/drop')(x)        out_node = Dense(nOutput, activation=activation, name=output_name)(x)        return out_node 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:25,代码来源:cnn_model-predictor.py


示例13: One_vs_One_Inception_v2

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def One_vs_One_Inception_v2(self, nOutput=2, input=[224, 224, 3]):        """            Builds a simple One_vs_One_Inception_v2 network with 2 inception layers (useful for ECOC models).        """        if len(input) == 3:            input_shape = tuple([input[2]] + input[0:2])        else:            input_shape = tuple(input)        self.model = Graph()        # Input        self.model.add_input(name='input', input_shape=input_shape)        # Inception Ea        out_Ea = self.__addInception('inceptionEa', 'input', 16, 8, 32, 8, 8, 8)        # Inception Eb        out_Eb = self.__addInception('inceptionEb', out_Ea, 8, 8, 16, 8, 4, 4)        # Average Pooling    pool_size=(7,7)        self.model.add_node(AveragePooling2D(pool_size=input_shape[1:], strides=(1, 1)), name='ave_pool/ECOC',                            input=out_Eb)        # Softmax        self.model.add_node(Flatten(), name='loss_OnevsOne/classifier_flatten', input='ave_pool/ECOC')        self.model.add_node(Dropout(0.5), name='loss_OnevsOne/drop', input='loss_OnevsOne/classifier_flatten')        self.model.add_node(Dense(nOutput, activation='softmax'), name='loss_OnevsOne', input='loss_OnevsOne/drop')        # Output        self.model.add_output(name='loss_OnevsOne/output', input='loss_OnevsOne') 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:27,代码来源:cnn_model-predictor.py


示例14: add_One_vs_One_Inception_v2

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def add_One_vs_One_Inception_v2(self, input, input_shape, id_branch, nOutput=2, activation='softmax'):        """            Builds a simple One_vs_One_Inception_v2 network with 2 inception layers on the top of the current model (useful for ECOC_loss models).        """        # Inception Ea        out_Ea = self.__addInception('inceptionEa_' + str(id_branch), input, 16, 8, 32, 8, 8, 8)        # Inception Eb        out_Eb = self.__addInception('inceptionEb_' + str(id_branch), out_Ea, 8, 8, 16, 8, 4, 4)        # Average Pooling    pool_size=(7,7)        self.model.add_node(AveragePooling2D(pool_size=input_shape[1:], strides=(1, 1)),                            name='ave_pool/ECOC_' + str(id_branch), input=out_Eb)        # Softmax        self.model.add_node(Flatten(),                            name='fc_OnevsOne_' + str(id_branch) + '/flatten', input='ave_pool/ECOC_' + str(id_branch))        self.model.add_node(Dropout(0.5),                            name='fc_OnevsOne_' + str(id_branch) + '/drop',                            input='fc_OnevsOne_' + str(id_branch) + '/flatten')        output_name = 'fc_OnevsOne_' + str(id_branch)        self.model.add_node(Dense(nOutput, activation=activation),                            name=output_name, input='fc_OnevsOne_' + str(id_branch) + '/drop')        return output_name 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:25,代码来源:cnn_model.py


示例15: apn_module

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def apn_module(self, x):        def right(x):            x = layers.AveragePooling2D()(x)            x = layers.Conv2D(self.classes, kernel_size=1, padding='same')(x)            x = layers.BatchNormalization()(x)            x = layers.Activation('relu')(x)            x = layers.UpSampling2D(interpolation='bilinear')(x)            return x        def conv(x, filters, kernel_size, stride):            x = layers.Conv2D(filters, kernel_size=kernel_size, strides=(stride, stride), padding='same')(x)            x = layers.BatchNormalization()(x)            x = layers.Activation('relu')(x)            return x        x_7 = conv(x, int(x.shape[-1]), 7, stride=2)        x_5 = conv(x_7, int(x.shape[-1]), 5, stride=2)        x_3 = conv(x_5, int(x.shape[-1]), 3, stride=2)        x_3_1 = conv(x_3, self.classes, 3, stride=1)        x_3_1_up = layers.UpSampling2D(interpolation='bilinear')(x_3_1)        x_5_1 = conv(x_5, self.classes, 5, stride=1)        x_3_5 = layers.add([x_5_1, x_3_1_up])        x_3_5_up = layers.UpSampling2D(interpolation='bilinear')(x_3_5)        x_7_1 = conv(x_7, self.classes, 3, stride=1)        x_3_5_7 = layers.add([x_7_1, x_3_5_up])        x_3_5_7_up = layers.UpSampling2D(interpolation='bilinear')(x_3_5_7)        x_middle = conv(x, self.classes, 1, stride=1)        x_middle = layers.multiply([x_3_5_7_up, x_middle])        x_right = right(x)        x_middle = layers.add([x_middle, x_right])        return x_middle 
开发者ID:JACKYLUO1991,项目名称:Face-skin-hair-segmentaiton-and-skin-color-evaluation,代码行数:37,代码来源:lednet.py


示例16: psp_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def psp_block(prev_layer, level, feature_map_shape, input_shape):    if input_shape == (512, 512):        kernel_strides_map = {1: [64, 64],                              2: [32, 32],                              3: [22, 21],                              6: [11, 9]}  # TODO: Level 6: Kernel correct, but stride not exactly the same as Pytorch    else:        raise ValueError("Pooling parameters for input shape " + input_shape + " are not defined.")    if K.image_data_format() == 'channels_last':        bn_axis = 3    else:        bn_axis = 1    names = [        "class_psp_" + str(level) + "_conv",        "class_psp_" + str(level) + "_bn"    ]    kernel = (kernel_strides_map[level][0], kernel_strides_map[level][0])    strides = (kernel_strides_map[level][1], kernel_strides_map[level][1])    prev_layer = AveragePooling2D(kernel, strides=strides)(prev_layer)    prev_layer = Conv2D(512, (1, 1), strides=(1, 1), name=names[0], use_bias=False)(prev_layer)    prev_layer = resnet.BN(bn_axis, name=names[1])(prev_layer)    prev_layer = Activation('relu')(prev_layer)    prev_layer = Upsampling(feature_map_shape)(prev_layer)    return prev_layer 
开发者ID:scaelles,项目名称:DEXTR-KerasTensorflow,代码行数:28,代码来源:classifiers.py


示例17: interp_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def interp_block(x, num_filters=512, level=1, input_shape=(512, 512, 3), output_stride=16):    feature_map_shape = (input_shape[0] / output_stride, input_shape[1] / output_stride)    # compute dataformat    if K.image_data_format() == 'channels_last':        bn_axis = 3    else:        bn_axis = 1    if output_stride == 16:        scale = 5    elif output_stride == 8:        scale = 10    kernel = (level*scale, level*scale)    strides = (level*scale, level*scale)    global_feat = AveragePooling2D(kernel, strides=strides, name='pool_level_%s_%s'%(level, output_stride))(x)    global_feat = _conv(            filters=num_filters,            kernel_size=(1, 1),            padding='same',            name='conv_level_%s_%s'%(level,output_stride))(global_feat)    global_feat = BatchNormalization(axis=bn_axis, name='bn_level_%s_%s'%(level, output_stride))(global_feat)    global_feat = Lambda(Interp, arguments={'shape': feature_map_shape})(global_feat)    return global_feat# squeeze and excitation function 
开发者ID:dhkim0225,项目名称:keras-image-segmentation,代码行数:31,代码来源:pspnet.py


示例18: interp_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def interp_block(prev_layer, level, feature_map_shape, input_shape):    if input_shape == (473, 473):        kernel_strides_map = {1: 60,                              2: 30,                              3: 20,                              6: 10}    elif input_shape == (713, 713):        kernel_strides_map = {1: 90,                              2: 45,                              3: 30,                              6: 15}    else:        print("Pooling parameters for input shape ",              input_shape, " are not defined.")        exit(1)    names = [        "conv5_3_pool" + str(level) + "_conv",        "conv5_3_pool" + str(level) + "_conv_bn"    ]    kernel = (kernel_strides_map[level], kernel_strides_map[level])    strides = (kernel_strides_map[level], kernel_strides_map[level])    prev_layer = AveragePooling2D(kernel, strides=strides)(prev_layer)    prev_layer = Conv2D(512, (1, 1), strides=(1, 1), name=names[0],                        use_bias=False)(prev_layer)    prev_layer = BN(name=names[1])(prev_layer)    prev_layer = Activation('relu')(prev_layer)    # prev_layer = Lambda(Interp, arguments={    #                    'shape': feature_map_shape})(prev_layer)    prev_layer = Interp(feature_map_shape)(prev_layer)    return prev_layer 
开发者ID:Vladkryvoruchko,项目名称:PSPNet-Keras-tensorflow,代码行数:33,代码来源:layers_builder.py


示例19: vgg_norm

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def vgg_norm():    img_input = Input(shape=(256, 256, 3))    x1 = Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv1')(img_input)    x2 = Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv2')(x1)    x3 = AveragePooling2D((2, 2), strides=(2, 2), name='block1_pool')(x2)    x4 = Conv2D(128, (3, 3), activation='relu', padding='same', name='block2_conv1')(x3)    x5 = Conv2D(128, (3, 3), activation='relu', padding='same', name='block2_conv2')(x4)    x6 = AveragePooling2D((2, 2), strides=(2, 2), name='block2_pool')(x5)    x7 = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv1')(x6)    x8 = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv2')(x7)    x9 = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv3')(x8)    x10 = Conv2D(256, (3, 3), activation='relu', padding='same', name='block3_conv4')(x9)    x11 = AveragePooling2D((2, 2), strides=(2, 2), name='block3_pool')(x10)    x12 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv1')(x11)    x13 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv2')(x12)    x14 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv3')(x13)    x15 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block4_conv4')(x14)    x16 = AveragePooling2D((2, 2), strides=(2, 2), name='block4_pool')(x15)    x17 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv1')(x16)    x18 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv2')(x17)    x19 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv3')(x18)    x20 = Conv2D(512, (3, 3), activation='relu', padding='same', name='block5_conv4')(x19)    x21 = AveragePooling2D((2, 2), strides=(2, 2), name='block5_pool')(x20)    model = Model(inputs=[img_input], outputs=[x1, x2, x4, x5, x7, x8, x9, x10, x12, x13, x14, x15])    model_orig = VGG19(weights='imagenet', input_shape=(256, 256, 3), include_top=False)    for i in range(len(model.layers)):        weights = model_orig.layers[i].get_weights()        model.layers[i].set_weights(weights)    return model 
开发者ID:balakg,项目名称:posewarp-cvpr2018,代码行数:38,代码来源:truncated_vgg.py


示例20: create_model

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def create_model():    #Data format:tensorflow,channels_last;theano,channels_last    if DATA_FORMAT=='channels_first':        INP_SHAPE=(3,299,299)        img_input=Input(shape=INP_SHAPE)        CONCAT_AXIS=1    elif DATA_FORMAT=='channels_last':        INP_SHAPE=(299,299,3)        img_input=Input(shape=INP_SHAPE)        CONCAT_AXIS=3    else:        raise Exception('Invalid Dim Ordering')    base_model = InceptionV3(weights='imagenet', include_top=False)    base_model.summary()    for layer in base_model.layers:        layer.trainable = False    x =  base_model.get_layer('mixed7').output           x = Convolution2D(512, (1, 1), kernel_initializer="glorot_uniform", padding="same", name="DenseNet_initial_conv2D", use_bias=False,                      kernel_regularizer=l2(WEIGHT_DECAY))(x)    x = BatchNormalization()(x)    x, nb_filter = dense_block(x, 5, 512, growth_rate=64,dropout_rate=0.5)    x = AveragePooling2D(pool_size=(7, 7), strides=1, padding='valid', data_format=DATA_FORMAT)(x)    x = Dense(512, activation='relu')(x)    #x = Dropout(0.5)(x)    x = Dense(16)(x)    x = Lambda(lambda x:tf.nn.l2_normalize(x))(x)    model = Model(inputs=base_model.input, outputs=x)    return model 
开发者ID:GerardLiu96,项目名称:FECNet,代码行数:40,代码来源:FECWithPretrained.py


示例21: add_transition

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def add_transition(input, num_filter = 12, dropout_rate = 0.2):    global weight_decay    BatchNorm = BatchNormalization()(input)    relu = Activation('relu')(BatchNorm)    Conv2D_BottleNeck = Conv2D(int(num_filter*compression), (1,1), use_bias=False, padding='same', kernel_initializer='he_normal', kernel_regularizer=l2(weight_decay))(relu)    if dropout_rate>0:      Conv2D_BottleNeck = Dropout(dropout_rate)(Conv2D_BottleNeck)    avg = AveragePooling2D(pool_size=(2,2))(Conv2D_BottleNeck)        return avg, int(num_filter*compression) 
开发者ID:ambujraj,项目名称:hacktoberfest2018,代码行数:12,代码来源:DenseNet_CIFAR10.py


示例22: output_layer

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def output_layer(input):    global compression    BatchNorm = BatchNormalization()(input)    relu = Activation('relu')(BatchNorm)    AvgPooling = AveragePooling2D(pool_size=(2,2))(relu)    flat = Flatten()(AvgPooling)    output = Dense(num_classes, activation='softmax')(flat)        return output 
开发者ID:ambujraj,项目名称:hacktoberfest2018,代码行数:11,代码来源:DenseNet_CIFAR10.py


示例23: modelMultiScaleDiscriminator

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import AveragePooling2D [as 别名]def modelMultiScaleDiscriminator(self, name=None):        x1 = Input(shape=self.img_shape)        x2 = AveragePooling2D(pool_size=(2, 2))(x1)        #x4 = AveragePooling2D(pool_size=(2, 2))(x2)        out_x1 = self.modelDiscriminator('D1')(x1)        out_x2 = self.modelDiscriminator('D2')(x2)        #out_x4 = self.modelDiscriminator('D4')(x4)        return Model(inputs=x1, outputs=[out_x1, out_x2], name=name) 
开发者ID:simontomaskarlsson,项目名称:CycleGAN-Keras,代码行数:12,代码来源:model.py


万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。