GoogLeNet Inception v1 结构 及 pytorch、tensorflow、keras、paddle实现ImageNet识别

背景

GoogLeNet是谷歌在imageNet上的ILSVRC 2014大赛冠军方案,论文“Going deeper with convolutions”网络主要部分有Inception模块组成,v1版本的核心思想是通过多个并行的稀疏结构代替密集结构,从而在扩大特征范围的同时减少计算量,同时使用1*1卷积再次减少卷积时的计算量。同时,在网络中间层增加了两个Loss,用来减弱梯度回传消失的情况。最终使网络的宽度和深度都有所增加.

 

网络结构

蓝色部分为并行的卷积,黄色是为降低计算量使用的1*1卷积,称为降维操作,红色为stride为1的池化(Additionally, since pooling operations have been essential for the success in current state of the art convolutional networks, it suggests that adding an alternative parallel pooling path in each such stage should have additional beefificial effect, too

1*1卷积降低计算量:假设inception输入为n*n*j,输出为n*n*k,原始版本中3*3卷积过程的参数量为j*3*3*j=9*jk,降维版本中的参数量为j*1*1*m+m*3*3*k=m(j+9k),其中m表示1*1降维卷积的通道数,由于j、k通道数可以达到几百甚至几千,所以只有m不是过大,降维版本的计算量会远小于原始版本

完整网络结构如上图,主体部分是inception模块,在训练时,在4a、4d的输出部分添加loss输出如下图:

• An average pooling layer with 5×5 fifilter size and stride 3, resulting in an 4×4×512 output for the (4a), and 4×4×528 for the (4d) stage.
• A 1×1 convolution with 128 fifilters for dimension reduction and rectifified linear activation.
• A fully connected layer with 1024 units and rectifified linear activation.
• A dropout layer with 70% ratio of dropped outputs.
• A linear layer with softmax loss as the classififier (predicting the same 1000 classes as the main classififier, but removed at inference time)
 

 

代码:

pytorch实现

tensorflow实现

keras实现

paddle实现

 

 

注:

以上代码在alexnet的基础上,实现了:

1)调用框架api读取数据集

2)进行train、val的流程

3)在train时可以输出各层shape

4)保存最优loss模型,并在结束时输出最优loss及对应epoch

5)在训练结束后查看loss、acc变化曲线

 

(实验数据集):UC Merced Land Use Dataset,常用的遥感场景分类数据集,21class * 100pic = 2100张图片,统一为256*256pix大小

http://weegee.vision.ucmerced.edu/datasets/landuse.html

(在pytorch上可以有有效收敛,在tensorflow、keras、paddle目前不收敛)

 

文件结构:my_utils.py文件存放通用函数

 

 

发布了126 篇原创文章 · 获赞 46 · 访问量 8万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章