GoogLeNet之InceptionV3神经网络简介与代码实战

InceptionV3在InceptionV2基础上优化了模型结构,如使用1xN和Nx1卷积减少参数量,适用于中等大小的特征图。文章介绍了InceptionV3的两个子结构InceptionV3a和InceptionV3b,并提供了Keras代码实现这两个子结构的详细过程。
摘要由CSDN通过智能技术生成

1.介绍

Inception V3与Inception V2是来自于同一篇论文,具体可以参见论文Rethinking the Inception Architecture for Computer Vision中。

 

2.模型结构

dba2a6a317ce0006726d92860a9d19f3.png

InceptionV3 a子结构

265b08cbbb5122e3aa5f66b83891e0dc.png

InceptionV3 b子结构

 

3.模型特点
Inception V3相比Inception V2进行了如下改进: 任意nxn的卷积都可以通过1xn卷积后接nx1卷积来替代,进一步减少参数量 ,但在实际上,作者发现在网络的前期使用这种分解效果并不好,只有在中度大小的feature map上使用效果才会更好,对于mxm大小的feature map,建议m在12到20之间。

 

4.代码实现 keras

def Conv2d(x, nb_filter, kernel_size, padding='same', strides=(1, 1)):
    x = Conv2D(nb_filter, kernel_size, padding=padding, strides=strides)(x)
    x = BatchNormalization(axis=3)(x)
    x = Activation('relu')(x)
    return x
 
 
def Inception_a(x, nb_filter=[128, 192]):
    branch0 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))
    branch0 = Conv2d(branch0, nb_filter[0], (7, 1), padding='same', strides=(1, 1))
    branch0 = Conv2d(branch0, nb_filter[0], (1, 7), padding='same', strides=(1, 1))
    branch0 = Conv2d(branch0, nb_filter[0], (7, 1), padding='same', strides=(1, 1))
    branch0 = Conv2d(branch0, nb_filter[1], (1, 7), padding='same', strides=(1, 1))
 
    branch1 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))
    branch1 = Conv2d(branch1, nb_filter[0], (7, 1), padding='same', strides=(1, 1))
    branch1 = Conv2d(branch1, nb_filter[1], (1, 7), padding='same', strides=(1, 1))
    
    branch2 = MaxPooling2D(pool_size=(3, 3), strides=(1, 1), padding='same')(x)
    branch2 = Conv2d(branch2, nb_filter[1], (1, 1), padding='same', strides=(1, 1))
    
    branch3 = Conv2d(x, nb_filter[1], (1, 1), padding='same', strides=(1, 1))
    
    x = concatenate([branch0, branch1, branch2, branch3], axis=3)
 
    return x
 
 
def Inception_b(x, nb_filter=[448, 384, 192, 320]):
    branch0 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))
    branch0 = Conv2d(branch0, nb_filter[1], (3, 3), padding='same', strides=(1, 1))
    branch0_1 = Conv2d(branch0, nb_filter[1], (3, 1), padding='same', strides=(1, 1))
    branch0_2 = Conv2d(branch0, nb_filter[1], (1, 3), padding='same', strides=(1, 1))
 
    branch1 = Conv2d(x, nb_filter[1], (1, 1), padding='same', strides=(1, 1))
    branch1_1 = Conv2d(branch1, nb_filter[1], (3, 1), padding='same', strides=(1, 1))
    branch1_2 = Conv2d(branch1, nb_filter[1], (1, 3), padding='same', strides=(1, 1))
    
    branch2 = MaxPooling2D(pool_size=(3, 3), strides=(1, 1), padding='same')(x)
    branch2 = Conv2d(branch2, nb_filter[2], (1, 1), padding='same', strides=(1, 1))
    
    branch3 = Conv2d(x, nb_filter[3], (1, 1), padding='same', strides=(1, 1))
    
    x = concatenate([branch0_1, branch0_2, branch1_1, branch1_2, branch2, branch3], axis=3)
    
    return x

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值