[Neural Network] (15) Xception code reproduction, network analysis, with complete Tensorflow code

Hello everyone, today I will share with you how to use Tensorflow to build an Xception neural network model.

In the previous chapters, I have introduced many kinds of lightweight convolutional neural network models, you can take a look if you are interested: https://blog.csdn.net/dgvv4/category_11517910.html

Xception is an algorithm that balances accuracy and light weight . As shown in the figure below, the horizontal axis represents the amount of calculation, and the vertical axis represents the accuracy. In terms of accuracy, Xception is in the first echelon, and in terms of calculation speed, it is also a lightweight network model.

Xception uses the depthwise separable convolution method of MobileNetV1. It is recommended that you learn MobileNetV1 first : https://blog.csdn.net/dgvv4/article/details/123415708


1. Depthwise Separable Convolution

In order to help you better grasp Xception, let's briefly review the method of depthwise separable convolution.

Ordinary convolution is a convolution kernel that processes all channels , how many channels the input feature map has, and the convolution kernel has several channels, and one convolution kernel generates a feature map.

Depthwise separable convolution can be understood as depthwise convolution + point-by-point convolution. Depth-wise convolution only processes spatial information in the
length and width directions ; point-by-point convolution only processes information in the cross-channel direction . It can greatly reduce the number of parameters and improve the calculation efficiency.

Depth convolution: A convolution kernel only processes one channel, that is, each convolution kernel only processes its own corresponding channel . There are as many convolution kernels as there are channels in the input feature map . The feature maps processed by each convolution kernel are stacked together. Input and output feature maps have the same number of channels.

Since only processing the information in the length and width directions will lead to the loss of cross-channel information, in order to supplement the cross-channel information, point-by-point convolution is required.

Point-by-point convolution: It uses 1x1 convolution to process the cross-channel dimension . How many 1x1 convolution kernels will generate as many feature maps .


2. From Inception to Xception

Next, I will sort out the improvement process of the core modules from Inception to Xception network to help you have a further understanding of the Xception structure.

First, InceptionV1 is composed of 9 BottleNeck-Inception modules stacked , as shown in the figure below.


2.1 Inception module

The principle of the Inception module: divide the input feature map into four branches, perform four different processing, and then stack the resulting feature maps processed by the four methods and input them to the next layer.

By decomposing and decoupling as much as possible, different scales and different convolutions are used to obtain information of different levels and strengths.


2.2 BottleNeck Module

As the output feature maps of the Inception module are continuously stacked , the number of channels in the feature maps will increase. In order to prevent more and more feature maps, the amount of operations and parameters explode. A 1x1 convolution is added before the 3x3 and 5x5 convolutions for dimensionality reduction, which controls the number of output feature maps and reduces the amount of parameters and computation . The picture on the left is the Inception module, and the picture on the right is the BottleNeck module.


2.3 Improvement process of Inception network

(1) First, InceptionV3 improves the BottleNeck module and decomposes the 5x5 convolution into two 3x3 convolutions. Two layers of 3x3 convolution instead of one layer of 5x5 convolution can obtain the same receptive field, reduce the amount of parameters, increase nonlinearity, and improve the expression ability of the model.

(2) Replace the 1x1 convolution after the pooling layer with a 3x3 convolution.

(3) The first layer uses 1x1 convolution, and the second layer uses 3x3 convolution.

(4) After the image is input, a 1x1 convolution is performed to generate a feature map, and the next three branches process this feature map.

(5) After the image is input, the feature map after 1x1 convolution is processed by group convolution . Different convolution kernels process different channels, and each group is independent of each other .

(6) The Xception module uses the idea of ​​depthwise separable convolution , first point-by-point convolution, then depthwise convolution , and each 3x3 convolution only processes one channel. The order of point-wise convolution and depth-wise convolution does not matter too much.


3. Code reproduction

3.1 Network Structure Diagram

The Xception network model structure given in the paper is shown in the figure below


3.2 Build each convolution module

(1) Standard convolution block

A standard convolution block consists of convolution + batch normalization + activation function

#(1)标准卷积模块
def conv_block(input_tensor, filters, kernel_size, stride):

    # 普通卷积+标准化+激活函数
    x = layers.Conv2D(filters = filters,  # 输出特征图个数
                      kernel_size = kernel_size,  # 卷积size
                      strides = stride,  # 步长
                      padding = 'same',  # 步长=1输出特征图size不变,步长=2特征图长宽减半
                      use_bias = False)(input_tensor)  # 有BN层就不需要偏置
    
    x = layers.BatchNormalization()(x)  # 批标准化

    x = layers.ReLU()(x)  # relu激活函数

    return x  # 返回标准卷积的输出特征图

(2) Residual block

As shown in the structure diagram, a residual unit is constructed, which consists of two depthwise separable convolution + max pooling + residual edge

#(2)深度可分离卷积模块
def sep_conv_block(input_tensor, filters, kernel_size):

    # 激活函数
    x = layers.ReLU()(input_tensor)

    # 深度可分离卷积函数,包含了(深度卷积+逐点卷积)
    x = layers.SeparableConvolution2D(filters = filters,  # 逐点卷积的卷积核个数,输出特征图个数
                                      kernel_size = kernel_size,  # 深度卷积的卷积核size
                                      strides = 1,  # 深度卷积的步长
                                      padding = 'same',  # 卷积过程中特征图size不变
                                      use_bias = False)(x)  # 有BN层就不要偏置
    
    return x  # 返回输出特征图


#(3)一个残差单元
def res_block(input_tensor, filters):

    # ① 残差边
    residual = layers.Conv2D(filters,  # 输出图像的通道数
                              kernel_size = (1,1),  # 卷积核size
                              strides = 2)(input_tensor)  # 使输入和输出的size相同

    residual = layers.BatchNormalization()(residual)  # 批标准化

    # ② 卷积块
    x = sep_conv_block(input_tensor, filters, kernel_size=(3,3))
    x = sep_conv_block(x, filters, kernel_size=(3,3))
    x = layers.MaxPooling2D(pool_size=(3,3), strides=2, padding='same')(x)

    # ③ 输入输出叠加,残差连接
    output = layers.Add()([residual, x])

    return output

3.3 Complete code display

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import Model, layers

#(1)标准卷积模块
def conv_block(input_tensor, filters, kernel_size, stride):

    # 普通卷积+标准化+激活函数
    x = layers.Conv2D(filters = filters,  # 输出特征图个数
                      kernel_size = kernel_size,  # 卷积size
                      strides = stride,  # 步长
                      padding = 'same',  # 步长=1输出特征图size不变,步长=2特征图长宽减半
                      use_bias = False)(input_tensor)  # 有BN层就不需要偏置
    
    x = layers.BatchNormalization()(x)  # 批标准化

    x = layers.ReLU()(x)  # relu激活函数

    return x  # 返回标准卷积的输出特征图


#(2)深度可分离卷积模块
def sep_conv_block(input_tensor, filters, kernel_size):

    # 激活函数
    x = layers.ReLU()(input_tensor)

    # 深度可分离卷积函数,包含了(深度卷积+逐点卷积)
    x = layers.SeparableConvolution2D(filters = filters,  # 逐点卷积的卷积核个数,输出特征图个数
                                      kernel_size = kernel_size,  # 深度卷积的卷积核size
                                      strides = 1,  # 深度卷积的步长
                                      padding = 'same',  # 卷积过程中特征图size不变
                                      use_bias = False)(x)  # 有BN层就不要偏置
    
    return x  # 返回输出特征图


#(3)一个残差单元
def res_block(input_tensor, filters):

    # ① 残差边
    residual = layers.Conv2D(filters,  # 输出图像的通道数
                              kernel_size = (1,1),  # 卷积核size
                              strides = 2)(input_tensor)  # 使输入和输出的size相同

    residual = layers.BatchNormalization()(residual)  # 批标准化

    # ② 卷积块
    x = sep_conv_block(input_tensor, filters, kernel_size=(3,3))
    x = sep_conv_block(x, filters, kernel_size=(3,3))
    x = layers.MaxPooling2D(pool_size=(3,3), strides=2, padding='same')(x)

    # ③ 输入输出叠加,残差连接
    output = layers.Add()([residual, x])

    return output


#(4)Middle Flow模块
def middle_flow(x, filters):

    # 该模块循环8次
    for _ in range(8): 

        # 残差边
        residual = x
        # 三个深度可分离卷积块
        x = sep_conv_block(x, filters, kernel_size=(3,3))
        x = sep_conv_block(x, filters, kernel_size=(3,3))
        x = sep_conv_block(x, filters, kernel_size=(3,3))
        # 叠加残差边
        x = layers.Add()([residual, x])

    return x


#(5)主干网络
def xception(input_shape, classes):

    # 构建输入
    inputs = keras.Input(shape=input_shape)

    # [299,299,3]==>[149,149,32]
    x = conv_block(inputs, filters=32, kernel_size=(3,3), stride=2)  # 标准卷积块
    # [149,149,32]==>[149,149,64]
    x = conv_block(x, filters=64, kernel_size=(3,3), stride=1)

    # [149,149,64]==>[75,75,128]
    # 残差边
    residual = layers.Conv2D(filters=128, kernel_size=(1,1), strides=2, 
                             padding='same', use_bias=False)(x)
    residual = layers.BatchNormalization()(residual)
    # 卷积块[149,149,64]==>[149,149,128]
    x = layers.SeparableConv2D(128, kernel_size=(3,3), strides=1, padding='same',use_bias=False)(x)
    x = layers.BatchNormalization()(x)
    # [149,149,128]==>[149,149,128]
    x = sep_conv_block(x, filters=128, kernel_size=(3,3))
    # [149,149,128]==>[75,75,128]
    x = layers.MaxPooling2D(pool_size=(3,3), strides=2, padding='same')(x)

    # [75,75,128]==>[38,38,256]
    x = res_block(x, filters=256)
    # [38,38,256]==>[19,19,728]
    x = res_block(x, filters=728)
    # [19,19,728]==>[19,19,728]
    x = middle_flow(x, filters=728)
    
    # 残差边模块[19,19,728]==>[10,10,1024]
    residual = layers.Conv2D(filters=1024, kernel_size=(1,1), 
                             strides=2, use_bias=False, padding='same')(x) 
    
    residual = layers.BatchNormalization()(residual)  # 批标准化

    # 卷积块[19,19,728]==>[19,19,728]
    x = sep_conv_block(x, filters=728, kernel_size=(3,3))
    # [19,19,728]==>[19,19,1024]
    x = sep_conv_block(x, filters=1024, kernel_size=(3,3))
    # [19,19,1024]==>[10,10,1024]
    x = layers.MaxPooling2D(pool_size=(3,3), strides=2, padding='same')(x)

    # 叠加残差边[10,10,1024]
    x = layers.Add()([residual, x])

    # [10,10,1024]==>[10,10,1536]
    x = layers.SeparableConv2D(1536, (3,3), padding='same', use_bias=False)(x)
    x = layers.BatchNormalization()(x)
    x = layers.ReLU()(x)
    
    # [10,10,1536]==>[10,10,2048]
    x = layers.SeparableConv2D(2048, (3,3), padding='same', use_bias=False)(x)
    x = layers.BatchNormalization()(x)
    x = layers.ReLU()(x)

    # [10,10,2048]==>[None,2048]
    x = layers.GlobalAveragePooling2D()(x)

    # [None,2048]==>[None,classes]
    outputs = layers.Dense(classes)(x)  # logits层不做softmax

    # 构建模型
    model = Model(inputs, outputs)

    return model


#(6)接收网络模型
if __name__ == '__main__':

    model = xception(input_shape=[299,299,3], classes=1000)

    model.summary()  # 查看网络模型结构

3.4 View the network architecture

View the network model framework through model.summary(), the number of network parameters is more than 20 million

Model: "model"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None, 299, 299, 3) 0                                            
__________________________________________________________________________________________________
conv2d (Conv2D)                 (None, 150, 150, 32) 864         input_1[0][0]                    
__________________________________________________________________________________________________
batch_normalization (BatchNorma (None, 150, 150, 32) 128         conv2d[0][0]                     
__________________________________________________________________________________________________
re_lu (ReLU)                    (None, 150, 150, 32) 0           batch_normalization[0][0]        
__________________________________________________________________________________________________
conv2d_1 (Conv2D)               (None, 150, 150, 64) 18432       re_lu[0][0]                      
__________________________________________________________________________________________________
batch_normalization_1 (BatchNor (None, 150, 150, 64) 256         conv2d_1[0][0]                   
__________________________________________________________________________________________________
re_lu_1 (ReLU)                  (None, 150, 150, 64) 0           batch_normalization_1[0][0]      
__________________________________________________________________________________________________
separable_conv2d (SeparableConv (None, 150, 150, 128 8768        re_lu_1[0][0]                    
__________________________________________________________________________________________________
batch_normalization_3 (BatchNor (None, 150, 150, 128 512         separable_conv2d[0][0]           
__________________________________________________________________________________________________
re_lu_2 (ReLU)                  (None, 150, 150, 128 0           batch_normalization_3[0][0]      
__________________________________________________________________________________________________
separable_conv2d_1 (SeparableCo (None, 150, 150, 128 17536       re_lu_2[0][0]                    
__________________________________________________________________________________________________
max_pooling2d (MaxPooling2D)    (None, 75, 75, 128)  0           separable_conv2d_1[0][0]         
__________________________________________________________________________________________________
re_lu_3 (ReLU)                  (None, 75, 75, 128)  0           max_pooling2d[0][0]              
__________________________________________________________________________________________________
separable_conv2d_2 (SeparableCo (None, 75, 75, 256)  33920       re_lu_3[0][0]                    
__________________________________________________________________________________________________
re_lu_4 (ReLU)                  (None, 75, 75, 256)  0           separable_conv2d_2[0][0]         
__________________________________________________________________________________________________
conv2d_3 (Conv2D)               (None, 38, 38, 256)  33024       max_pooling2d[0][0]              
__________________________________________________________________________________________________
separable_conv2d_3 (SeparableCo (None, 75, 75, 256)  67840       re_lu_4[0][0]                    
__________________________________________________________________________________________________
batch_normalization_4 (BatchNor (None, 38, 38, 256)  1024        conv2d_3[0][0]                   
__________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D)  (None, 38, 38, 256)  0           separable_conv2d_3[0][0]         
__________________________________________________________________________________________________
add (Add)                       (None, 38, 38, 256)  0           batch_normalization_4[0][0]      
                                                                 max_pooling2d_1[0][0]            
__________________________________________________________________________________________________
re_lu_5 (ReLU)                  (None, 38, 38, 256)  0           add[0][0]                        
__________________________________________________________________________________________________
separable_conv2d_4 (SeparableCo (None, 38, 38, 728)  188672      re_lu_5[0][0]                    
__________________________________________________________________________________________________
re_lu_6 (ReLU)                  (None, 38, 38, 728)  0           separable_conv2d_4[0][0]         
__________________________________________________________________________________________________
conv2d_4 (Conv2D)               (None, 19, 19, 728)  187096      add[0][0]                        
__________________________________________________________________________________________________
separable_conv2d_5 (SeparableCo (None, 38, 38, 728)  536536      re_lu_6[0][0]                    
__________________________________________________________________________________________________
batch_normalization_5 (BatchNor (None, 19, 19, 728)  2912        conv2d_4[0][0]                   
__________________________________________________________________________________________________
max_pooling2d_2 (MaxPooling2D)  (None, 19, 19, 728)  0           separable_conv2d_5[0][0]         
__________________________________________________________________________________________________
add_1 (Add)                     (None, 19, 19, 728)  0           batch_normalization_5[0][0]      
                                                                 max_pooling2d_2[0][0]            
__________________________________________________________________________________________________
re_lu_7 (ReLU)                  (None, 19, 19, 728)  0           add_1[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_6 (SeparableCo (None, 19, 19, 728)  536536      re_lu_7[0][0]                    
__________________________________________________________________________________________________
re_lu_8 (ReLU)                  (None, 19, 19, 728)  0           separable_conv2d_6[0][0]         
__________________________________________________________________________________________________
separable_conv2d_7 (SeparableCo (None, 19, 19, 728)  536536      re_lu_8[0][0]                    
__________________________________________________________________________________________________
re_lu_9 (ReLU)                  (None, 19, 19, 728)  0           separable_conv2d_7[0][0]         
__________________________________________________________________________________________________
separable_conv2d_8 (SeparableCo (None, 19, 19, 728)  536536      re_lu_9[0][0]                    
__________________________________________________________________________________________________
add_2 (Add)                     (None, 19, 19, 728)  0           add_1[0][0]                      
                                                                 separable_conv2d_8[0][0]         
__________________________________________________________________________________________________
re_lu_10 (ReLU)                 (None, 19, 19, 728)  0           add_2[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_9 (SeparableCo (None, 19, 19, 728)  536536      re_lu_10[0][0]                   
__________________________________________________________________________________________________
re_lu_11 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_9[0][0]         
__________________________________________________________________________________________________
separable_conv2d_10 (SeparableC (None, 19, 19, 728)  536536      re_lu_11[0][0]                   
__________________________________________________________________________________________________
re_lu_12 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_10[0][0]        
__________________________________________________________________________________________________
separable_conv2d_11 (SeparableC (None, 19, 19, 728)  536536      re_lu_12[0][0]                   
__________________________________________________________________________________________________
add_3 (Add)                     (None, 19, 19, 728)  0           add_2[0][0]                      
                                                                 separable_conv2d_11[0][0]        
__________________________________________________________________________________________________
re_lu_13 (ReLU)                 (None, 19, 19, 728)  0           add_3[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_12 (SeparableC (None, 19, 19, 728)  536536      re_lu_13[0][0]                   
__________________________________________________________________________________________________
re_lu_14 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_12[0][0]        
__________________________________________________________________________________________________
separable_conv2d_13 (SeparableC (None, 19, 19, 728)  536536      re_lu_14[0][0]                   
__________________________________________________________________________________________________
re_lu_15 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_13[0][0]        
__________________________________________________________________________________________________
separable_conv2d_14 (SeparableC (None, 19, 19, 728)  536536      re_lu_15[0][0]                   
__________________________________________________________________________________________________
add_4 (Add)                     (None, 19, 19, 728)  0           add_3[0][0]                      
                                                                 separable_conv2d_14[0][0]        
__________________________________________________________________________________________________
re_lu_16 (ReLU)                 (None, 19, 19, 728)  0           add_4[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_15 (SeparableC (None, 19, 19, 728)  536536      re_lu_16[0][0]                   
__________________________________________________________________________________________________
re_lu_17 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_15[0][0]        
__________________________________________________________________________________________________
separable_conv2d_16 (SeparableC (None, 19, 19, 728)  536536      re_lu_17[0][0]                   
__________________________________________________________________________________________________
re_lu_18 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_16[0][0]        
__________________________________________________________________________________________________
separable_conv2d_17 (SeparableC (None, 19, 19, 728)  536536      re_lu_18[0][0]                   
__________________________________________________________________________________________________
add_5 (Add)                     (None, 19, 19, 728)  0           add_4[0][0]                      
                                                                 separable_conv2d_17[0][0]        
__________________________________________________________________________________________________
re_lu_19 (ReLU)                 (None, 19, 19, 728)  0           add_5[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_18 (SeparableC (None, 19, 19, 728)  536536      re_lu_19[0][0]                   
__________________________________________________________________________________________________
re_lu_20 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_18[0][0]        
__________________________________________________________________________________________________
separable_conv2d_19 (SeparableC (None, 19, 19, 728)  536536      re_lu_20[0][0]                   
__________________________________________________________________________________________________
re_lu_21 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_19[0][0]        
__________________________________________________________________________________________________
separable_conv2d_20 (SeparableC (None, 19, 19, 728)  536536      re_lu_21[0][0]                   
__________________________________________________________________________________________________
add_6 (Add)                     (None, 19, 19, 728)  0           add_5[0][0]                      
                                                                 separable_conv2d_20[0][0]        
__________________________________________________________________________________________________
re_lu_22 (ReLU)                 (None, 19, 19, 728)  0           add_6[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_21 (SeparableC (None, 19, 19, 728)  536536      re_lu_22[0][0]                   
__________________________________________________________________________________________________
re_lu_23 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_21[0][0]        
__________________________________________________________________________________________________
separable_conv2d_22 (SeparableC (None, 19, 19, 728)  536536      re_lu_23[0][0]                   
__________________________________________________________________________________________________
re_lu_24 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_22[0][0]        
__________________________________________________________________________________________________
separable_conv2d_23 (SeparableC (None, 19, 19, 728)  536536      re_lu_24[0][0]                   
__________________________________________________________________________________________________
add_7 (Add)                     (None, 19, 19, 728)  0           add_6[0][0]                      
                                                                 separable_conv2d_23[0][0]        
__________________________________________________________________________________________________
re_lu_25 (ReLU)                 (None, 19, 19, 728)  0           add_7[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_24 (SeparableC (None, 19, 19, 728)  536536      re_lu_25[0][0]                   
__________________________________________________________________________________________________
re_lu_26 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_24[0][0]        
__________________________________________________________________________________________________
separable_conv2d_25 (SeparableC (None, 19, 19, 728)  536536      re_lu_26[0][0]                   
__________________________________________________________________________________________________
re_lu_27 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_25[0][0]        
__________________________________________________________________________________________________
separable_conv2d_26 (SeparableC (None, 19, 19, 728)  536536      re_lu_27[0][0]                   
__________________________________________________________________________________________________
add_8 (Add)                     (None, 19, 19, 728)  0           add_7[0][0]                      
                                                                 separable_conv2d_26[0][0]        
__________________________________________________________________________________________________
re_lu_28 (ReLU)                 (None, 19, 19, 728)  0           add_8[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_27 (SeparableC (None, 19, 19, 728)  536536      re_lu_28[0][0]                   
__________________________________________________________________________________________________
re_lu_29 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_27[0][0]        
__________________________________________________________________________________________________
separable_conv2d_28 (SeparableC (None, 19, 19, 728)  536536      re_lu_29[0][0]                   
__________________________________________________________________________________________________
re_lu_30 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_28[0][0]        
__________________________________________________________________________________________________
separable_conv2d_29 (SeparableC (None, 19, 19, 728)  536536      re_lu_30[0][0]                   
__________________________________________________________________________________________________
add_9 (Add)                     (None, 19, 19, 728)  0           add_8[0][0]                      
                                                                 separable_conv2d_29[0][0]        
__________________________________________________________________________________________________
re_lu_31 (ReLU)                 (None, 19, 19, 728)  0           add_9[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_30 (SeparableC (None, 19, 19, 728)  536536      re_lu_31[0][0]                   
__________________________________________________________________________________________________
re_lu_32 (ReLU)                 (None, 19, 19, 728)  0           separable_conv2d_30[0][0]        
__________________________________________________________________________________________________
conv2d_5 (Conv2D)               (None, 10, 10, 1024) 745472      add_9[0][0]                      
__________________________________________________________________________________________________
separable_conv2d_31 (SeparableC (None, 19, 19, 1024) 752024      re_lu_32[0][0]                   
__________________________________________________________________________________________________
batch_normalization_6 (BatchNor (None, 10, 10, 1024) 4096        conv2d_5[0][0]                   
__________________________________________________________________________________________________
max_pooling2d_3 (MaxPooling2D)  (None, 10, 10, 1024) 0           separable_conv2d_31[0][0]        
__________________________________________________________________________________________________
add_10 (Add)                    (None, 10, 10, 1024) 0           batch_normalization_6[0][0]      
                                                                 max_pooling2d_3[0][0]            
__________________________________________________________________________________________________
separable_conv2d_32 (SeparableC (None, 10, 10, 1536) 1582080     add_10[0][0]                     
__________________________________________________________________________________________________
batch_normalization_7 (BatchNor (None, 10, 10, 1536) 6144        separable_conv2d_32[0][0]        
__________________________________________________________________________________________________
re_lu_33 (ReLU)                 (None, 10, 10, 1536) 0           batch_normalization_7[0][0]      
__________________________________________________________________________________________________
separable_conv2d_33 (SeparableC (None, 10, 10, 2048) 3159552     re_lu_33[0][0]                   
__________________________________________________________________________________________________
batch_normalization_8 (BatchNor (None, 10, 10, 2048) 8192        separable_conv2d_33[0][0]        
__________________________________________________________________________________________________
re_lu_34 (ReLU)                 (None, 10, 10, 2048) 0           batch_normalization_8[0][0]      
__________________________________________________________________________________________________
global_average_pooling2d (Globa (None, 2048)         0           re_lu_34[0][0]                   
__________________________________________________________________________________________________
dense (Dense)                   (None, 1000)         2049000     global_average_pooling2d[0][0]   
==================================================================================================
Total params: 22,817,480
Trainable params: 22,805,848
Non-trainable params: 11,632
__________________________________________________________________________________________________

Guess you like

Origin blog.csdn.net/dgvv4/article/details/123460427