Deep Learning Practical Chapter (15) -- GoogLeNet of TensorFlow

Scientific knowledge

The full English name of AAAI is the Association for the Advance of Artificial Intelligence, and the Chinese meaning is the Association for the Advance of Artificial Intelligence.

American Association for Artificial Intelligence is one of the main academic organizations in the field of artificial intelligence. The annual meeting (AAAI, The National Conference on Artificial Intelligence) hosted by the association is a major artificial intelligence academic conference.

e44e0407dcef06cf72d3ec6c4d7025d5.png

# Preface

SEP.

In the last article of the theoretical chapter, we learned about the GoogLeNet network. Its core is the Inception module. Through this module, the neural network can be designed very deep. Today we will use TensorFlow to carry out the actual combat of the Inception module. I hope you like it.

98b349c8db520e1e2a11e40980cf3ff7.png

TensorFlow's Inception combat

d72a9dc664c7b0a2f264d23ea4c4dead.png

In this actual combat, we use the facial expression data set for training. The model is mainly the Inception module. Since it is only a demo, we only design a simple layer. The code will be open sourced to gitee.

1. Data preparation

96835e9e70d7387e049e4c8fa68853b3.png

This time the data uses the RAFDB facial expression dataset, which contains seven categories: peaceful, happy, sad,

Surprised, disgusted, angry, scared. Similar to the previous dataset, this facial expression dataset also contains

Training set and test set, each set does not contain 7 folders (expressions). with the previous dataset

Same, the data set contains training set and test set, each set contains seven folders (expressions)

  some samples show

b8e0120c8cb7475cbaa0b2858b0cf59e.png

f86bb0f449cd61757063a47ebd0dd458.png

2. Network structure

9d1025f540dc512cd88608d620c70d3b.png

1c590660a82692a94913fcae7a4b6fda.png

The network structure is as above, because it is very simple to change the module, we will not carefully analyze the parameters of the network, the specific parameters can be seen from the previous article (Deep Learning Theory (16) -- GoogLeNet's re-exploration of depth Mystery ), from the code below, you should be able to see the dimensional transformation of each layer, which is really incomprehensible, I believe that as long as you debug carefully, there will be no problem, it is recommended to print the dimension information of each line of code, and it will be clear Know how the feature map changes step by step in the network.

def inference(images, batch_size, n_classes,drop_rate):
    
    #左1x1 conv
    conv1 = Conv_layer(names = 'conv_block1', input = images , w_shape = [1, 1, 3, 128], b_shape = [128], strid = [1, 1])
    # print("******** conv1 {} ".format(conv1.shape))


    #1x1 conv
    conv2 = Conv_layer(names = 'conv_block2', input = images , w_shape = [1, 1, 3, 64], b_shape = [64], strid = [1, 1])
    # 第二层卷积1
    conv2_1 = Conv_layer(names = 'conv_block2_1', input = conv2 , w_shape = [3, 3, 64, 192], b_shape = [192], strid = [1, 1])
    # print("******** conv2_1 {} ".format(conv2_1.shape))


    #1x1 conv
    conv3 = Conv_layer(names = 'conv_block3', input = images , w_shape = [1, 1, 3, 64], b_shape = [64], strid = [1, 1])
    # 第二层卷积2
    conv3_1 = Conv_layer(names = 'conv_block3_1', input = conv3 , w_shape = [5, 5, 64, 96], b_shape = [96], strid = [1, 1])
    # print("******** conv3_1 {} ".format(conv3_1.shape))


    #3x3 max pooling
    pool_1 = Max_pool_lrn(names = 'pooling1', input = images , ksize = [1, 3, 3, 1], is_lrn = False)
    # 第二层卷积2
    conv4 = Conv_layer(names = 'conv_block4', input = pool_1 , w_shape = [1, 1, 3, 64], b_shape = [64], strid = [1, 1])
    print("******** conv4 {} ".format(conv4.shape))


    concat_op = tf.concat([conv1, conv2_1, conv3_1, conv4],3)
    conv5 = Conv_layer(names = 'conv_block5', input = concat_op , w_shape = [1, 1, 480, 64], b_shape = [64], strid = [1, 1])
    # print("******** concat_op {} ".format(concat_op.shape))


If you look at the network structure carefully, I added a layer of 1x1 convolution to the last layer of the output, the purpose is why,

Of course, there is no mine at home, so I can only reduce the dimension.

3. Training process

de0aad998c09f84a0c01f0deca8245f5.png

3eb048f510d11928cf5dcadc037d0378.png

Source code acquisition: https://gitee.com/fengyuxiexie/inception

576dd68d06ed9448cbf64dfe396d50e9.gif

END

epilogue

  The sharing of this issue is over. The module is very simple. I hope that students will also contact more. In addition, this time we have added a new facial expression dataset. Students who need it can consult in the background.

Editor: Layman Yueyi|Review: Layman Xiaoquanquan

708e6f291d1ba1f6d02220d5be713da5.png

Advanced IT Tour

Past review

Deep Learning Practical Chapter (14) -- VGG16 of TensorFlow

Deep Learning Practical Chapter (13) -- AlexNet of TensorFlow

Deep Learning Practical Chapter (12) -- LetNet-5 of TensorFlow

What have we done in the past year:

[Year-end Summary] Saying goodbye to the old and welcoming the new, 2020, let's start again

[Year-end summary] 2021, bid farewell to the old and welcome the new

fb44def5a8bf149473b581f0971ae4e2.gif

Click "Like" and let's go~

Guess you like

Origin blog.csdn.net/xyl666666/article/details/121600968