论文简读(二)

inception v1

流程

- 整体框架
- 论文的目的
- 论文中的创新点
- keras代码实现

整体框架

  • inception模块的设计
    在这里插入图片描述该论文加入inception模块,(b)相比于(a)来说,在3x3h和5x5的卷积前加入了1x1的卷积用来降维,也就是减少channel数,这样大大减少计算量。为什么要这样设计呢?因为inception v1之前的网络都是一条路走到黑,通过加深网络来提高准确率,但这样大大增加了计算量。而inception模块增加了网络的深度和宽度,利用小卷积,既增加网络结构的深度,又减少了计算量,还提高了网络的准确率。
  • 网络结构表
    在这里插入图片描述从表中来看,除了inception模块,其他还是常规操作

论文的目的

  • 减少计算参数量,减少训练时间
  • 提高网络内部的资源利用率
  • 既增加网络的深度又增加网络的宽度,还提升了准确率

论文中的创新点

  • 1x1小卷积的提出,用于降维,减少了计算参数
  • 最后使用了averagepool来适应网络的如何输入尺寸
  • 加入了中间层输出分支,在较低层进行分类并进行梯度的反向传播

keras代码实现

import keras
from keras.layers import Input,Dense,Conv2D,MaxPool2D,BatchNormalization
from keras.layers import concatenate,AvgPool2D,Dropout,Flatten
from keras.models import Model
from keras.utils import plot_model

# inception模块
def Inception(inputs=None,filter1=None,kernel1=1,filter3=None,kernel3=3,filter5=None,kernel5=5):
	# 1x1降维
    _1x1 = Conv2D(filters=filter1[0],kernel_size=kernel1,padding="same",activation="relu")(inputs)
    
    # 1x1降维
    reduce_1x1_3 = Conv2D(filters=filter1[1],kernel_size=kernel1,padding="same",activation="relu")(inputs)
    _3x3 = Conv2D(filters=filter3,kernel_size=kernel3,padding="same",activation="relu")(reduce_1x1_3)
    
    # 1x1降维
    reduce_1x1_5 = Conv2D(filters=filter1[2],kernel_size=kernel1,padding="same",activation="relu")(inputs)
    _5x5 = Conv2D(filters=filter5,kernel_size=kernel5,padding="same",activation="relu")(reduce_1x1_5)
    
    maxpool = MaxPool2D(pool_size=3,strides=1,padding="same")(inputs)
    # 1x1降维
    _1x1_max = Conv2D(filters=filter1[3],kernel_size=kernel1,padding="same",activation="relu")(maxpool)
    
    # 在通道上合并
    out = concatenate([_1x1,_3x3,_5x5,_1x1_max])
    return out

# 分支输出模块
def output(net=None):
    net = AvgPool2D(pool_size=5,strides=3,padding="valid")(net)
    net = Conv2D(filters=128,kernel_size=1,strides=1,padding="valid",activation="relu")(net)
    net = Dense(units=1024,activation="relu")(net)
    net = Dropout(rate=0.7)(net)
    out = Dense(units=1000,activation="softmax")(net)
    return out

# 网络结构 --> 对着表看,很清晰
def Inception_v1():
    inputs = Input(shape=(224, 224, 3))
    
    net = Conv2D(filters=64, kernel_size=7,strides=2,padding="same",activation="relu")(inputs)
    net = BatchNormalization()(net)
    net = MaxPool2D(pool_size=3, strides=2, padding="same")(net)
    
    net = Conv2D(filters=64, kernel_size=1,strides=1,padding="same",activation="relu")(net)
    net = Conv2D(filters=192, kernel_size=3, strides=1,padding="same", activation="relu")(net)
    net = BatchNormalization()(net)
    net = MaxPool2D(pool_size=3, strides=2, padding="same")(net)
    
    net = Inception(inputs=net,filter1=[64,96,16,32],filter3=128,filter5=32)
    net = Inception(inputs=net,filter1=[128,128,32,64],filter3=192,filter5=96)
    net = MaxPool2D(pool_size=3, strides=2, padding="same")(net)
    
    net = Inception(inputs=net,filter1=[192,96,16,64],filter3=208,filter5=48)
    out1 = output(net)
    net = Inception(inputs=net,filter1=[160,112,24,64],filter3=224,filter5=64)
    net = Inception(inputs=net,filter1=[128,128,24,64],filter3=256,filter5=64)
    net = Inception(inputs=net,filter1=[112,144,32,64],filter3=288,filter5=64)
    out2 = output(net)
    net = Inception(inputs=net,filter1=[256,160,32,128],filter3=320,filter5=128)
    net = MaxPool2D(pool_size=3, strides=2,padding="same")(net)

    net = Inception(inputs=net,filter1=[256,160,32,128],filter3=320,filter5=32)
    net = Inception(inputs=net,filter1=[384,192,48,128],filter3=384,filter5=48)
    net = AvgPool2D(pool_size=7, strides=1,padding="valid")(net)
    
    net = Flatten()(net)
    net = Dropout(rate=0.4)(net)
    out3 = Dense(units=1000, activation="softmax")(net)
    
    model = Model(inputs=[inputs], outputs=[out1, out2, out3])
    return model

# 画出结构图并保存
model = Inception_v1()
plot_model(model, to_file='model.png',show_shapes=True,dpi=150)
  • 网络结构图
    在这里插入图片描述
  • 每天进步一点点
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值