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

1.介绍

Inception V4出自于论文Inception-v4, Inception-ResNet andthe Impact of Residual Connections on Learning中,从论文名字,我们就知道Inception V4是由Inception V3和ResNet改进而来。

 

2.模型结构

Inception V4 里面子模块比较多,但结构比较类似,这里就不一一介绍.

GoogLeNet之InceptionV4神经网络简介与代码实战_第1张图片

                    InceptionV4 a子结构

GoogLeNet之InceptionV4神经网络简介与代码实战_第2张图片

                              InceptionV4 b子结构  

 

3.模型特点

Inception V4相比Inception V3进行了如下改进: 引进残差网络,但论文说引入resnet不是用来提高深度(提高准确度),只是用来提高速度的。

 

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, 896]):
    branch0 = x

    branch1 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))

    branch2 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))
    branch2 = Conv2d(branch2, nb_filter[0], (7, 1), padding='same', strides=(1, 1))
    branch2 = Conv2d(branch2, nb_filter[0], (1, 7), padding='same', strides=(1, 1))

    branch1_2 = concatenate([branch1, branch2], axis=3)
    branch1_2 = Conv2d(branch1_2, nb_filter[1], (1, 1), padding='same', strides=(1, 1))

    y = Add()([branch0, branch1_2])
    y = Activation('relu')(y)

    return y


def Inception_b(x, nb_filter=[192, 128, 160, 1154]):
    branch0 = x

    branch1 = Conv2d(x, nb_filter[0], (1, 1), padding='same', strides=(1, 1))

    branch2 = Conv2d(x, nb_filter[1], (1, 1), padding='same', strides=(1, 1))
    branch2 = Conv2d(branch2, nb_filter[2], (7, 1), padding='same', strides=(1, 1))
    branch2 = Conv2d(branch2, nb_filter[0], (1, 7), padding='same', strides=(1, 1))

    branch1_2 = concatenate([branch1, branch2], axis=3)
    branch1_2 = Conv2d(branch1_2, nb_filter[3], (1, 1), padding='same', strides=(1, 1))

    y = Add()([branch0, branch1_2])
    y = Activation('relu')(y)

    return y

 

你可能感兴趣的:(深度学习CNN基本模型,深度学习CNN基本模型)