get_model.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:explainable-cnn 作者: blengerich 项目源码 文件源码
def get_simple_cnn(height, width):
    """ A simple CNN that has the same input/output shapes as the VGG16 model.

    Args:
        height: input height
        width: input width
    Return: Keras model

    """
    model = Sequential()
    model.add(ZeroPadding2D((1, 1), input_shape=(3, height, width)))
    model.add(Convolution2D(64, 3, 3, activation='relu'))
    model.add(MaxPooling2D((4, 4), strides=(2, 2)))

    model.add(ZeroPadding2D((1, 1)))
    model.add(Convolution2D(64, 3, 3, activation='relu'))
    model.add(MaxPooling2D((4, 4), strides=(2, 2)))

    #model.add(ZeroPadding2D((1, 1)))
    #model.add(Convolution2D(64, 3, 3, activation='relu'))
    #model.add(MaxPooling2D((4, 4), strides=(2, 2)))

    #model.add(ZeroPadding2D((1, 1)))
    #model.add(Convolution2D(512, 3, 3, activation='relu'))
    #model.add(MaxPooling2D((2, 2), strides=(2, 2)))

    model.add(ZeroPadding2D((1, 1)))
    model.add(Convolution2D(64, 3, 3, activation='relu'))
    model.add(Lambda(global_average_pooling,
                     output_shape=global_average_pooling_shape))
    model.add(Dense(2, activation="softmax", init="uniform"))
    return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号