动手学计算机视觉---inception v4 源码分析

动手学计算机视觉--1

第一章,第4篇,上篇内容中对网络结构以及代码实现进行了一一对应,使用keras搭建网络模型往往更加直观,本篇主要内容如下:

继续完成网络主结构代码阅读,简单介绍其余文件的作用,介绍专栏接下来的内容

1 代码阅读

网络结构

    if include_top:
        # 1 x 1 x 1536
        x = AveragePooling2D((8,8), padding='valid')(x)  #使用均值池化操作
        x = Dropout(dropout_keep_prob)(x)                #使用剪纸操作
        x = Flatten()(x)                                 #将x展开
        # 1536
        x = Dense(units=num_classes, activation='softmax')(x)  #全连接,并使用softmax预测

    model = Model(inputs, x, name='inception_v4')

模型加载

# load weights
    if weights == 'imagenet':
        if K.image_data_format() == 'channels_first':
            if K.backend() == 'tensorflow':
                warnings.warn('You are using the TensorFlow backend, yet you '
                              'are using the Theano '
                              'image data format convention '
                              '(`image_data_format="channels_first"`). '
                              'For best performance, set '
                              '`image_data_format="channels_last"` in '
                              'your Keras config '
                              'at ~/.keras/keras.json.')
#下面将根据逻辑加载两种不同的权重
        if include_top:
            '''
            weights_path = get_file(
                'inception-v4_weights_tf_dim_ordering_tf_kernels.h5',
                WEIGHTS_PATH,
                cache_subdir='models',
                md5_hash='9fe79d77f793fe874470d84ca6ba4a3b')
            '''
            weights_path = "E:/keras-inceptionV4-master/inception-v4_weights_tf_dim_ordering_tf_kernels.h5"
        else:
            weights_path = get_file(
                'inception-v4_weights_tf_dim_ordering_tf_kernels_notop.h5',
                WEIGHTS_PATH_NO_TOP,
                cache_subdir='models',
                md5_hash='9296b46b5971573064d12e4669110969')
##下面是keras中加载模型权重的方法,model.load_weights()
        model.load_weights(weights_path, by_name=True)
    return model

 

2 文件介绍

validation_utils,为标签转换工具,convert_weights主要为模型权重转换代码(不同框架的模型文件格式有所不同)

3 后续介绍

第一章内容到此结束,在第一章内容中,通过图像分类的例子,分析了网络结构与代码的对应关系,简单讨论了包管理工具Anaconda与集成开发环境Pycharm

在专栏第二章内容中,将介绍深度学习与计算机视觉结合时常用的操作,包括二维卷积,填充,池化等内容,主要使用框架MXNET

更多内容请持续关注

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值