Inception 又叫Googlenet是Google于2014年为参加ILSVRC大赛而提出的CNN分类模型。它发表于2014年的CVPR上面。在深度学习领域Google出品几乎必为精品,Inception也不例外。
通过把不同尺寸的卷积核如1x1,3x3,5x5进行堆叠增加了网络对不同尺度的适应性。并且通过在3x3的网络,5x5的网络后加入1x1使得网络的计算复杂度降低,而且提高网络的非线性的程度,基于更强的表征能力。
def Conv2d(x, nb_filter,kernel_size, padding='same',strides=(1,1)):
x = Conv2D(nb_filter,kernel_size,padding=padding,strides=strides,activation='relu')(x)
return x
def Inception_a(x,nb_filter=[128,192,96]):
branch1x1 = Conv2d(x,nb_filter[0],(1,1), padding='same',strides=(1,1))
branch3x3 = Conv2d(x,nb_filter[1],(3,3), padding='same',strides=(1,1))
branch5x5 = Conv2d(x,nb_filter[2],(5,5), padding='same',strides=(1,1))
branchpool = MaxPooling2D(pool_size=(3,3),strides=(1,1),padding='same')(x)
x = concatenate([branch1x1,branch3x3,branch5x5,branchpool],axis=3)
return x
def Inception_b(x,nb_filter=[128,128,192,32,96,64]):
branch1x1 = Conv2d(x,nb_filter[0],(1,1), padding='same',strides=(1,1))
branch3x3 = Conv2d(x,nb_filter[1],(1,1), padding='same',strides=(1,1))
branch3x3 = Conv2d(branch3x3,nb_filter[2],(3,3), padding='same',strides=(1,1))
branch5x5 = Conv2d(x,nb_filter[3],(1,1), padding='same',strides=(1,1))
branch5x5 = Conv2d(branch5x5,nb_filter[4],(5,5), padding='same',strides=(1,1))
branchpool = MaxPooling2D(pool_size=(3,3),strides=(1,1),padding='same')(x)
branchpool = Conv2d(branchpool,nb_filter[5],(1,1),padding='same',strides=(1,1))
x = concatenate([branch1x1,branch3x3,branch5x5,branchpool],axis=3)