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

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

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

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

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

示例1: gettest_model

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def gettest_model():    input = Input(shape=[16, 66, 3])  # change this shape to [None,None,3] to enable arbitraty shape input    A = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)    B = Activation("relu", name='relu1')(A)    C = MaxPool2D(pool_size=2)(B)    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(C)    x = Activation("relu", name='relu2')(x)    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)    K = Activation("relu", name='relu3')(x)    x = Flatten()(K)    dense = Dense(2,name = "dense")(x)    output = Activation("relu", name='relu4')(dense)    x = Model([input], [output])    x.load_weights("./model/model12.h5")    ok = Model([input], [dense])    for layer in ok.layers:        print(layer)    return ok 
开发者ID:fanghon,项目名称:lpr,代码行数:24,代码来源:finemapping_vertical.py


示例2: convolutional_autoencoder

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def convolutional_autoencoder():    input_shape=(28,28,1)    n_channels = input_shape[-1]    model = Sequential()    model.add(Conv2D(32, (3,3), activation='relu', padding='same', input_shape=input_shape))    model.add(MaxPool2D(padding='same'))    model.add(Conv2D(16, (3,3), activation='relu', padding='same'))    model.add(MaxPool2D(padding='same'))    model.add(Conv2D(8, (3,3), activation='relu', padding='same'))    model.add(UpSampling2D())    model.add(Conv2D(16, (3,3), activation='relu', padding='same'))    model.add(UpSampling2D())    model.add(Conv2D(32, (3,3), activation='relu', padding='same'))    model.add(Conv2D(n_channels, (3,3), activation='sigmoid', padding='same'))    return model 
开发者ID:otenim,项目名称:AnomalyDetectionUsingAutoencoder,代码行数:18,代码来源:models.py


示例3: model_definition

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def model_definition():        """ Keras RNetwork for MTCNN """        input_ = Input(shape=(24, 24, 3))        var_x = Conv2D(28, (3, 3), strides=1, padding='valid', name='conv1')(input_)        var_x = PReLU(shared_axes=[1, 2], name='prelu1')(var_x)        var_x = MaxPool2D(pool_size=3, strides=2, padding='same')(var_x)        var_x = Conv2D(48, (3, 3), strides=1, padding='valid', name='conv2')(var_x)        var_x = PReLU(shared_axes=[1, 2], name='prelu2')(var_x)        var_x = MaxPool2D(pool_size=3, strides=2)(var_x)        var_x = Conv2D(64, (2, 2), strides=1, padding='valid', name='conv3')(var_x)        var_x = PReLU(shared_axes=[1, 2], name='prelu3')(var_x)        var_x = Permute((3, 2, 1))(var_x)        var_x = Flatten()(var_x)        var_x = Dense(128, name='conv4')(var_x)        var_x = PReLU(name='prelu4')(var_x)        classifier = Dense(2, activation='softmax', name='conv5-1')(var_x)        bbox_regress = Dense(4, name='conv5-2')(var_x)        return [input_], [classifier, bbox_regress] 
开发者ID:deepfakes,项目名称:faceswap,代码行数:22,代码来源:mtcnn.py


示例4: create_Kao_Onet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Kao_Onet( weight_path = 'model48.h5'):    input = Input(shape = [48,48,3])    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1,2],name='prelu1')(x)    x = MaxPool2D(pool_size=3, strides=2, padding='same')(x)    x = Conv2D(64, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1,2],name='prelu2')(x)    x = MaxPool2D(pool_size=3, strides=2)(x)    x = Conv2D(64, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1,2],name='prelu3')(x)    x = MaxPool2D(pool_size=2)(x)    x = Conv2D(128, (2, 2), strides=1, padding='valid', name='conv4')(x)    x = PReLU(shared_axes=[1,2],name='prelu4')(x)    x = Permute((3,2,1))(x)    x = Flatten()(x)    x = Dense(256, name='conv5') (x)    x = PReLU(name='prelu5')(x)    classifier = Dense(2, activation='softmax',name='conv6-1')(x)    bbox_regress = Dense(4,name='conv6-2')(x)    landmark_regress = Dense(10,name='conv6-3')(x)    model = Model([input], [classifier, bbox_regress, landmark_regress])    model.load_weights(weight_path, by_name=True)    return model 
开发者ID:wotchin,项目名称:SmooFaceEngine,代码行数:27,代码来源:mtcnn_model.py


示例5: create_Kao_Rnet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Kao_Rnet (weight_path = 'model24.h5'):    input = Input(shape=[24, 24, 3])  # change this shape to [None,None,3] to enable arbitraty shape input    x = Conv2D(28, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1, 2], name='prelu1')(x)    x = MaxPool2D(pool_size=3,strides=2, padding='same')(x)    x = Conv2D(48, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1, 2], name='prelu2')(x)    x = MaxPool2D(pool_size=3, strides=2)(x)    x = Conv2D(64, (2, 2), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1, 2], name='prelu3')(x)    x = Permute((3, 2, 1))(x)    x = Flatten()(x)    x = Dense(128, name='conv4')(x)    x = PReLU( name='prelu4')(x)    classifier = Dense(2, activation='softmax', name='conv5-1')(x)    bbox_regress = Dense(4, name='conv5-2')(x)    model = Model([input], [classifier, bbox_regress])    model.load_weights(weight_path, by_name=True)    return model 
开发者ID:wotchin,项目名称:SmooFaceEngine,代码行数:23,代码来源:mtcnn_model.py


示例6: get_convnet_landslide_all

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def get_convnet_landslide_all(args) -> Model:    input_shape = (args.area_size, args.area_size, 14)    model = Sequential()    model.add(Conv2D(8, 3, 3, input_shape=input_shape, init='normal'))    model.add(Activation('relu'))    model.add(Conv2D(8, 3, 3, init='normal'))    model.add(Activation('relu'))    model.add(MaxPool2D((1, 1), strides=(1, 1)))    model.add(Dropout(0.25))    model.add(Flatten(name="flatten"))    #    model.add(Dense(512, activation='relu', name='dense', init='normal'))    model.add(Dropout(0.25))    model.add(Dense(1, name='last_layer'))    model.add(Activation('sigmoid'))        return model 
开发者ID:rknaebel,项目名称:landslide,代码行数:19,代码来源:networks.py


示例7: get_model_1

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def get_model_1(args):    model = Sequential()    model.add(Conv2D(32, (5, 5), input_shape=(args.area_size, args.area_size, 14)))    model.add(Activation('relu'))    model.add(Conv2D(16, (3, 3)))    model.add(Activation('relu'))    model.add(MaxPool2D((1, 1), strides=(1, 1)))    model.add(Dropout(0.25))    #    model.add(AvgPool2D((3, 3), strides=(1, 1)))    model.add(Flatten(name="flatten"))    #    model.add(Dense(1, name='last_layer'))    model.add(Activation('sigmoid'))    return model 
开发者ID:rknaebel,项目名称:landslide,代码行数:18,代码来源:networks.py


示例8: get_model_cifar

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def get_model_cifar(args):    model = Sequential()    model.add(Conv2D(32, (3, 3), padding='same', input_shape=(args.area_size, args.area_size, 14)))    model.add(Activation('relu'))    model.add(Conv2D(32, (3, 3)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(2, 2)))    model.add(Dropout(0.25))    model.add(Conv2D(64, (3, 3), padding='same'))    model.add(Activation('relu'))    model.add(Conv2D(64, (3, 3)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(2, 2)))    model.add(Dropout(0.25))    model.add(Flatten())    model.add(Dense(512))    model.add(Activation('relu'))    model.add(Dropout(0.5))    model.add(Dense(1))    model.add(Activation('sigmoid'))    return model 
开发者ID:rknaebel,项目名称:landslide,代码行数:27,代码来源:networks.py


示例9: create_Pnet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Pnet(weight_path):    input = Input(shape=[None, None, 3])    x = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1,2],name='PReLU1')(x)    x = MaxPool2D(pool_size=2)(x)    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1,2],name='PReLU2')(x)    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1,2],name='PReLU3')(x)    classifier = Conv2D(2, (1, 1), activation='softmax', name='conv4-1')(x)    # 无激活函数,线性。    bbox_regress = Conv2D(4, (1, 1), name='conv4-2')(x)    model = Model([input], [classifier, bbox_regress])    model.load_weights(weight_path, by_name=True)    return model#-----------------------------##   mtcnn的第二段#   精修框#-----------------------------# 
开发者ID:bubbliiiing,项目名称:mtcnn-keras,代码行数:27,代码来源:mtcnn.py


示例10: down_sample

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def down_sample(self, x, filters):        x_filters = int(x.shape[-1])        x_conv = layers.Conv2D(filters - x_filters, kernel_size=3, strides=(2, 2), padding='same')(x)        x_pool = layers.MaxPool2D()(x)        x = layers.concatenate([x_conv, x_pool], axis=-1)        x = layers.BatchNormalization()(x)        x = layers.Activation('relu')(x)        return x 
开发者ID:JACKYLUO1991,项目名称:Face-skin-hair-segmentaiton-and-skin-color-evaluation,代码行数:10,代码来源:lednet.py


示例11: _SPP_block

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def _SPP_block(inp, kernels, strides):    pools = [MaxPool2D(pool_size = pool_size, strides = stride, padding = 'same')(inp) /             for pool_size, stride in zip(kernels, strides)]    pools = [inp] + pools    return concatenate(pools)#Downsampling block is common to all YOLO-v3 models and are unaffected by the SPP or fully connected blocks or the number of labes 
开发者ID:produvia,项目名称:ai-platform,代码行数:10,代码来源:yolov3_weights_to_keras.py


示例12: create_Pnet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Pnet(weight_path):    # h,w    input = Input(shape=[None, None, 3])    # h,w,3 -> h/2,w/2,10    x = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1,2],name='PReLU1')(x)    x = MaxPool2D(pool_size=2)(x)    # h/2,w/2,10 -> h/2,w/2,16    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1,2],name='PReLU2')(x)    # h/2,w/2,32    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1,2],name='PReLU3')(x)    # h/2, w/2, 2    classifier = Conv2D(2, (1, 1), activation='softmax', name='conv4-1')(x)    # 无激活函数,线性。    # h/2, w/2, 4    bbox_regress = Conv2D(4, (1, 1), name='conv4-2')(x)    model = Model([input], [classifier, bbox_regress])    model.load_weights(weight_path, by_name=True)    return model#-----------------------------##   mtcnn的第二段#   精修框#-----------------------------# 
开发者ID:bubbliiiing,项目名称:keras-face-recognition,代码行数:32,代码来源:mtcnn.py


示例13: create_Rnet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Rnet(weight_path):    input = Input(shape=[24, 24, 3])    # 24,24,3 -> 11,11,28    x = Conv2D(28, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1, 2], name='prelu1')(x)    x = MaxPool2D(pool_size=3,strides=2, padding='same')(x)    # 11,11,28 -> 4,4,48    x = Conv2D(48, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1, 2], name='prelu2')(x)    x = MaxPool2D(pool_size=3, strides=2)(x)    # 4,4,48 -> 3,3,64    x = Conv2D(64, (2, 2), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1, 2], name='prelu3')(x)    # 3,3,64 -> 64,3,3    x = Permute((3, 2, 1))(x)    x = Flatten()(x)    # 576 -> 128    x = Dense(128, name='conv4')(x)    x = PReLU( name='prelu4')(x)    # 128 -> 2 128 -> 4    classifier = Dense(2, activation='softmax', name='conv5-1')(x)    bbox_regress = Dense(4, name='conv5-2')(x)    model = Model([input], [classifier, bbox_regress])    model.load_weights(weight_path, by_name=True)    return model#-----------------------------##   mtcnn的第三段#   精修框并获得五个点#-----------------------------# 
开发者ID:bubbliiiing,项目名称:keras-face-recognition,代码行数:34,代码来源:mtcnn.py


示例14: create_Onet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Onet(weight_path):    input = Input(shape = [48,48,3])    # 48,48,3 -> 23,23,32    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1,2],name='prelu1')(x)    x = MaxPool2D(pool_size=3, strides=2, padding='same')(x)    # 23,23,32 -> 10,10,64    x = Conv2D(64, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1,2],name='prelu2')(x)    x = MaxPool2D(pool_size=3, strides=2)(x)    # 8,8,64 -> 4,4,64    x = Conv2D(64, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1,2],name='prelu3')(x)    x = MaxPool2D(pool_size=2)(x)    # 4,4,64 -> 3,3,128    x = Conv2D(128, (2, 2), strides=1, padding='valid', name='conv4')(x)    x = PReLU(shared_axes=[1,2],name='prelu4')(x)    # 3,3,128 -> 128,3,3    x = Permute((3,2,1))(x)    # 1152 -> 256    x = Flatten()(x)    x = Dense(256, name='conv5') (x)    x = PReLU(name='prelu5')(x)    # 鉴别    # 256 -> 2 256 -> 4 256 -> 10     classifier = Dense(2, activation='softmax',name='conv6-1')(x)    bbox_regress = Dense(4,name='conv6-2')(x)    landmark_regress = Dense(10,name='conv6-3')(x)    model = Model([input], [classifier, bbox_regress, landmark_regress])    model.load_weights(weight_path, by_name=True)    return model 
开发者ID:bubbliiiing,项目名称:keras-face-recognition,代码行数:37,代码来源:mtcnn.py


示例15: tiny_yolo_main

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def tiny_yolo_main(input, num_anchors, num_classes):    network_1 = NetworkConv2D_BN_Leaky(input=input, channels=16, kernel_size=(3,3) )    network_1 = MaxPool2D(pool_size=(2,2), strides=(2,2), padding="same")(network_1)    network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=32, kernel_size=(3, 3))    network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)    network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=64, kernel_size=(3, 3))    network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)    network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=128, kernel_size=(3, 3))    network_1 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)    network_1 = NetworkConv2D_BN_Leaky(input=network_1, channels=256, kernel_size=(3, 3))    network_2 = MaxPool2D(pool_size=(2, 2), strides=(2, 2), padding="same")(network_1)    network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=512, kernel_size=(3, 3))    network_2 = MaxPool2D(pool_size=(2, 2), strides=(1, 1), padding="same")(network_2)    network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=1024, kernel_size=(3, 3))    network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=256, kernel_size=(1, 1))    network_3 = NetworkConv2D_BN_Leaky(input=network_2, channels=512, kernel_size=(3, 3))    network_3 = Conv2D(num_anchors * (num_classes + 5),  kernel_size=(1,1))(network_3)    network_2 = NetworkConv2D_BN_Leaky(input=network_2, channels=128, kernel_size=(1, 1))    network_2 = UpSampling2D(2)(network_2)    network_4 = Concatenate()([network_2, network_1])    network_4 = NetworkConv2D_BN_Leaky(input=network_4, channels=256, kernel_size=(3, 3))    network_4 = Conv2D(num_anchors * (num_classes + 5), kernel_size=(1,1))(network_4)    return Model(input, [network_3, network_4]) 
开发者ID:OlafenwaMoses,项目名称:ImageAI,代码行数:30,代码来源:models.py


示例16: Getmodel_tensorflow

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def Getmodel_tensorflow(nb_classes):    # nb_classes = len(charset)    img_rows, img_cols = 9, 34    # number of convolutional filters to use    nb_filters = 32    # size of pooling area for max pooling    nb_pool = 2    # convolution kernel size    nb_conv = 3    # x = np.load('x.npy')    # y = np_utils.to_categorical(range(3062)*45*5*2, nb_classes)    # weight = ((type_class - np.arange(type_class)) / type_class + 1) ** 3    # weight = dict(zip(range(3063), weight / weight.mean()))  # 调整权重,高频字优先    model = Sequential()    model.add(Conv2D(16, (5, 5),input_shape=(img_rows, img_cols,3)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Flatten())    model.add(Dense(64))    model.add(Activation('relu'))    model.add(Dropout(0.5))    model.add(Dense(nb_classes))    model.add(Activation('softmax'))    model.compile(loss='categorical_crossentropy',                  optimizer='adam',                  metrics=['accuracy'])    return model 
开发者ID:fanghon,项目名称:lpr,代码行数:32,代码来源:typeDistinguish.py


示例17: getModel

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def getModel():    input = Input(shape=[16, 66, 3])  # change this shape to [None,None,3] to enable arbitraty shape input    x = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = Activation("relu", name='relu1')(x)    x = MaxPool2D(pool_size=2)(x)    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = Activation("relu", name='relu2')(x)    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = Activation("relu", name='relu3')(x)    x = Flatten()(x)    output = Dense(2,name = "dense")(x)    output = Activation("relu", name='relu4')(output)    model = Model([input], [output])    return model 
开发者ID:fanghon,项目名称:lpr,代码行数:16,代码来源:finemapping_vertical.py


示例18: Getmodel_tensorflow

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def Getmodel_tensorflow(nb_classes):    # nb_classes = len(charset)    img_rows, img_cols = 23, 23    # number of convolutional filters to use    nb_filters = 16    # size of pooling area for max pooling    nb_pool = 2    # convolution kernel size    nb_conv = 3    # x = np.load('x.npy')    # y = np_utils.to_categorical(range(3062)*45*5*2, nb_classes)    # weight = ((type_class - np.arange(type_class)) / type_class + 1) ** 3    # weight = dict(zip(range(3063), weight / weight.mean()))  # 调整权重,高频字优先    model = Sequential()    model.add(Conv2D(nb_filters, (nb_conv, nb_conv),input_shape=(img_rows, img_cols,1)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Conv2D(nb_filters, (nb_conv, nb_conv)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Flatten())    model.add(Dense(256))    model.add(Dropout(0.5))    model.add(Activation('relu'))    model.add(Dense(nb_classes))    model.add(Activation('softmax'))    model.compile(loss='categorical_crossentropy',                  optimizer='sgd',                  metrics=['accuracy'])    return model 
开发者ID:fanghon,项目名称:lpr,代码行数:34,代码来源:segmentation.py


示例19: Getmodel_tensorflow_light

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def Getmodel_tensorflow_light(nb_classes):    # nb_classes = len(charset)    img_rows, img_cols = 23, 23    # number of convolutional filters to use    nb_filters = 8    # size of pooling area for max pooling    nb_pool = 2    # convolution kernel size    nb_conv = 3    # x = np.load('x.npy')    # y = np_utils.to_categorical(range(3062)*45*5*2, nb_classes)    # weight = ((type_class - np.arange(type_class)) / type_class + 1) ** 3    # weight = dict(zip(range(3063), weight / weight.mean()))  # 调整权重,高频字优先    model = Sequential()    model.add(Conv2D(nb_filters, (nb_conv, nb_conv),input_shape=(img_rows, img_cols, 1)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Conv2D(nb_filters, (nb_conv * 2, nb_conv * 2)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Flatten())    model.add(Dense(32))    # model.add(Dropout(0.25))    model.add(Activation('relu'))    model.add(Dense(nb_classes))    model.add(Activation('softmax'))    model.compile(loss='categorical_crossentropy',                  optimizer='adam',                  metrics=['accuracy'])    return model 
开发者ID:fanghon,项目名称:lpr,代码行数:34,代码来源:segmentation.py


示例20: Getmodel_ch

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def Getmodel_ch(nb_classes):    # nb_classes = len(charset)    img_rows, img_cols = 23, 23    # number of convolutional filters to use    nb_filters = 32    # size of pooling area for max pooling    nb_pool = 2    # convolution kernel size    nb_conv = 3    # x = np.load('x.npy')    # y = np_utils.to_categorical(range(3062)*45*5*2, nb_classes)    # weight = ((type_class - np.arange(type_class)) / type_class + 1) ** 3    # weight = dict(zip(range(3063), weight / weight.mean()))  # 调整权重,高频字优先    model = Sequential()    model.add(Conv2D(32, (5, 5),input_shape=(img_rows, img_cols,1)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Dropout(0.25))    model.add(Conv2D(32, (3, 3)))    model.add(Activation('relu'))    model.add(MaxPool2D(pool_size=(nb_pool, nb_pool)))    model.add(Dropout(0.25))    model.add(Conv2D(512, (3, 3)))    # model.add(Activation('relu'))    # model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))    # model.add(Dropout(0.25))    model.add(Flatten())    model.add(Dense(756))    model.add(Activation('relu'))    model.add(Dropout(0.5))    model.add(Dense(nb_classes))    model.add(Activation('softmax'))    model.compile(loss='categorical_crossentropy',                  optimizer='adam',                  metrics=['accuracy'])    return model 
开发者ID:fanghon,项目名称:lpr,代码行数:41,代码来源:recognizer.py


示例21: ResNet50

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def ResNet50(input_shape, num_classes=10):    input_object = Input(shape=input_shape)    layers = [3, 4, 6, 3]    channel_depths = [256, 512, 1024, 2048]    output = Conv2D(64, kernel_size=7, strides=2, padding="same", kernel_initializer="he_normal")(input_object)    output = BatchNormalization()(output)    output = Activation("relu")(output)    output = MaxPool2D(pool_size=(3, 3), strides=(2, 2))(output)    output = resnet_first_block_first_module(output, channel_depths[0])    for i in range(4):        channel_depth = channel_depths[i]        num_layers = layers[i]        strided_pool_first = True        if (i == 0):            strided_pool_first = False            num_layers = num_layers - 1        output = resnet_block(output, channel_depth=channel_depth, num_layers=num_layers,                              strided_pool_first=strided_pool_first)    output = GlobalAvgPool2D()(output)    output = Dense(num_classes)(output)    output = Activation("softmax")(output)    model = Model(inputs=input_object, outputs=output)    return model 
开发者ID:OlafenwaMoses,项目名称:IdenProf,代码行数:32,代码来源:idenprof.py


示例22: create_model

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_model(self, hyper_parameters):        """            构建神经网络        :param hyper_parameters:json,  hyper parameters of network        :return: tensor, moedl        """        super().create_model(hyper_parameters)        embedding = self.word_embedding.output        embedding_reshape = Reshape((self.len_max, self.embed_size, 1))(embedding)        # 提取n-gram特征和最大池化, 一般不用平均池化        conv_pools = []        for filter in self.filters:            conv = Conv2D(filters = self.filters_num,                          kernel_size = (filter, self.embed_size),                          padding = 'valid',                          kernel_initializer = 'normal',                          activation = 'relu',                          )(embedding_reshape)            pooled = MaxPool2D(pool_size = (self.len_max - filter + 1, 1),                               strides = (1, 1),                               padding = 'valid',                               )(conv)            conv_pools.append(pooled)        # 拼接        x = Concatenate(axis=-1)(conv_pools)        x = Flatten()(x)        x = Dropout(self.dropout)(x)        output = Dense(units=self.label, activation=self.activate_classify)(x)        self.model = Model(inputs=self.word_embedding.input, outputs=output)        self.model.summary(120) 
开发者ID:yongzhuo,项目名称:Keras-TextClassification,代码行数:32,代码来源:graph.py


示例23: main

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def main():    input_tensor = Input((72, 272, 3))    x = input_tensor    print("build model")    x = Conv2D(32, kernel_size=(3, 3), activation='relu')(x)    x = Conv2D(32, kernel_size=(3, 3), activation='relu')(x)    x = MaxPool2D(pool_size=(2, 2))(x)    x = Conv2D(64, kernel_size=(3, 3), activation='relu')(x)    x = Conv2D(64, kernel_size=(3, 3), activation='relu')(x)    x = MaxPool2D(pool_size=(2, 2))(x)    x = Dropout(0.3)(x)    x = Conv2D(128, kernel_size=(3, 3), activation='relu')(x)    x = Conv2D(128, kernel_size=(3, 3), activation='relu')(x)    x = MaxPool2D(pool_size=(2, 2))(x)    x = Dropout(0.3)(x)    x = Flatten()(x)    x = Dropout(0.5)(x)    n_class = len(chars)    x = [Dense(n_class, activation='softmax', name='c{0}'.format(i + 1))(x) for i in range(7)]    model = Model(inputs=input_tensor, outputs=x)        print("compile model")    adam = Adam(lr=0.001)    model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy'])    # display     plot_model(model,to_file='./models/licenseplate_model.png')    # training    print("training model")    best_model = ModelCheckpoint("./models/licenseplate.h5", monitor='val_loss', verbose=0, save_best_only=True)    model.fit_generator(gen_plate(), steps_per_epoch=2000, epochs=8, validation_data=gen_plate(),                     validation_steps=1280, callbacks=[best_model]) 
开发者ID:jarvisqi,项目名称:deep_learning,代码行数:39,代码来源:licenseplate.py


示例24: to_real_keras_layer

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def to_real_keras_layer(layer):    """    Real keras layer.    """    from keras import layers    if is_layer(layer, "Dense"):        return layers.Dense(layer.units, input_shape=(layer.input_units,))    if is_layer(layer, "Conv"):        return layers.Conv2D(            layer.filters,            layer.kernel_size,            input_shape=layer.input.shape,            padding="same",        )  # padding    if is_layer(layer, "Pooling"):        return layers.MaxPool2D(2)    if is_layer(layer, "BatchNormalization"):        return layers.BatchNormalization(input_shape=layer.input.shape)    if is_layer(layer, "Concatenate"):        return layers.Concatenate()    if is_layer(layer, "Add"):        return layers.Add()    if is_layer(layer, "Dropout"):        return keras_dropout(layer, layer.rate)    if is_layer(layer, "ReLU"):        return layers.Activation("relu")    if is_layer(layer, "Softmax"):        return layers.Activation("softmax")    if is_layer(layer, "Flatten"):        return layers.Flatten()    if is_layer(layer, "GlobalAveragePooling"):        return layers.GlobalAveragePooling2D()    return None  # note: this is not written by original author, feel free to modify if you think it's incorrect 
开发者ID:microsoft,项目名称:nni,代码行数:36,代码来源:layers.py


示例25: create_Kao_Pnet

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def create_Kao_Pnet( weight_path = 'model12old.h5'):    input = Input(shape=[None, None, 3])    x = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)    x = PReLU(shared_axes=[1,2],name='PReLU1')(x)    x = MaxPool2D(pool_size=2)(x)    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(x)    x = PReLU(shared_axes=[1,2],name='PReLU2')(x)    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)    x = PReLU(shared_axes=[1,2],name='PReLU3')(x)    classifier = Conv2D(2, (1, 1), activation='softmax', name='conv4-1')(x)    bbox_regress = Conv2D(4, (1, 1), name='conv4-2')(x)    model = Model([input], [classifier, bbox_regress])    model.load_weights(weight_path, by_name=True)    return model 
开发者ID:wotchin,项目名称:SmooFaceEngine,代码行数:16,代码来源:mtcnn_model.py


示例26: get_model_2

# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import MaxPool2D [as 别名]def get_model_2(args):    model = Sequential()    model.add(Conv2D(32, (5, 1), padding="same", input_shape=(args.area_size, args.area_size, 14)))    model.add(Activation('relu'))    model.add(Conv2D(32, (1, 5), padding="same"))    model.add(Maxout())    model.add(Conv2D(32, (5, 1), padding="same"))    model.add(Activation('relu'))    model.add(Conv2D(32, (1, 5), padding="same"))    model.add(Maxout())    model.add(MaxPool2D(pool_size=(2, 2)))    model.add(Dropout(0.25))    #    model.add(Conv2D(16, (3, 1), padding="same"))    model.add(Activation('relu'))    model.add(Conv2D(16, (1, 3), padding="same"))    model.add(Maxout())    model.add(Conv2D(16, (3, 1), padding="same"))    model.add(Activation('relu'))    model.add(Conv2D(16, (1, 3), padding="same"))    model.add(Maxout())    model.add(MaxPool2D(pool_size=(2, 2)))    model.add(Dropout(0.25))    #    model.add(AvgPool2D((3, 3), strides=(1, 1)))    model.add(Flatten(name="flatten"))    #    model.add(Dense(1, name='last_layer'))    model.add(Activation('sigmoid'))    return model 
开发者ID:rknaebel,项目名称:landslide,代码行数:33,代码来源:networks.py


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