【神经网络】(15) Xception 代码复现,网络解析,附Tensorflow完整代码
各位同學好,今天和大家分享一下如何使用 Tensorflow 構(gòu)建 Xception 神經(jīng)網(wǎng)絡(luò)模型。
在前面章節(jié)中,我已經(jīng)介紹了很多種輕量化卷積神經(jīng)網(wǎng)絡(luò)模型,感興趣的可以看一下:https://blog.csdn.net/dgvv4/category_11517910.html
Xception 是一種兼顧了準確性和輕量化的算法。如下圖所示,橫軸表示計算量,縱軸表示準確率。在準確率上,Xception是排在第一梯隊的,且在計算速度上,也算是輕量化網(wǎng)絡(luò)模型。
Xception 使用了 MobileNetV1 的深度可分離卷積方法,建議大家先學習一下 MobileNetV1:https://blog.csdn.net/dgvv4/article/details/123415708
1. 深度可分離卷積
為了幫助大家更好地掌握 Xception,先簡單地復(fù)習一下深度可分離卷積的方法。
普通卷積是一個卷積核處理所有的通道,輸入特征圖有多少個通道,卷積核就有幾個通道,一個卷積核生成一張?zhí)卣鲌D。
深度可分離卷積 可理解為 深度卷積 + 逐點卷積
深度卷積只處理長寬方向的空間信息;逐點卷積只處理跨通道方向的信息。能大大減少參數(shù)量,提高計算效率
深度卷積: 是一個卷積核只處理一個通道,即每個卷積核只處理自己對應(yīng)的通道。輸入特征圖有多少個通道就有多少個卷積核。將每個卷積核處理后的特征圖堆疊在一起。輸入和輸出特征圖的通道數(shù)相同。
由于只處理長寬方向的信息會導致丟失跨通道信息,為了將跨通道的信息補充回來,需要進行逐點卷積。
逐點卷積: 是使用1x1卷積對跨通道維度處理,有多少個1x1卷積核就會生成多少個特征圖。
2. 從 Inception 到 Xception
接下來梳理一下從Inception到Xception網(wǎng)絡(luò)的核心模塊的改進過程,幫助大家對Xception結(jié)構(gòu)有進一步的認識。
首先 InceptionV1 是由9個 BottleNeck-Inception 模塊堆疊而成,如下圖所示。
2.1 Inception模塊
Inception模塊的原理: 將輸入的特征圖分成四個分支,進行四種不同的處理,再將四種方法處理的結(jié)果特征圖堆疊起來,輸入到下一層。
通過盡可能多的分解和解耦,用不同的尺度、不同的卷積來獲取不同層次,不同力度的信息。
2.2 BottleNeck模塊
隨著 Inception 模塊的輸出特征圖不斷的堆疊,特征圖的通道數(shù)會越來越多。為了防止特征圖越來越多,運算量和參數(shù)量爆炸。在 3x3 和 5x5 卷積之前添加了1x1卷積進行降維,控制輸出特征圖的數(shù)量,減少參數(shù)量和計算量。左圖為Inception模塊,右圖為BottleNeck模塊。
2.3 Inception 網(wǎng)絡(luò)的改進過程
(1)首先 InceptionV3 改進了 BottleNeck 模塊,將 5x5 卷積分解成兩個 3x3 卷積。兩層3x3卷積代替一層5x5卷積,可以獲得相同的感受野,減少參數(shù)量,增加非線性,提高模型的表達能力。
(2)將池化層后的1x1卷積換成3x3卷積。
(3)第一層全使用1x1卷積,第二層全使用3x3卷積。
(4)圖像輸入進來后,先經(jīng)過一次1x1卷積生成特征圖,接下來三個分支都對這個特征圖處理。
(5)圖像輸入后,使用分組卷積對1x1卷積后的特征圖處理,不同的卷積核處理不同的通道,各分組之間相互獨立。
(6)Xception模塊,使用深度可分離卷積思想,先逐點卷積,后深度卷積,每個3x3卷積只處理一個通道。逐點卷積和深度卷積的先后次序并太大無影響。
3. 代碼復(fù)現(xiàn)
3.1 網(wǎng)絡(luò)結(jié)構(gòu)圖
論文中給出的 Xception 網(wǎng)絡(luò)模型結(jié)構(gòu)如下圖所示
3.2 搭建各個卷積模塊
(1)標準卷積塊
一個標準卷積塊由 卷積+批標準化+激活函數(shù) 組成
#(1)標準卷積模塊
def conv_block(input_tensor, filters, kernel_size, stride):# 普通卷積+標準化+激活函數(shù)x = layers.Conv2D(filters = filters, # 輸出特征圖個數(shù)kernel_size = kernel_size, # 卷積sizestrides = stride, # 步長padding = 'same', # 步長=1輸出特征圖size不變,步長=2特征圖長寬減半use_bias = False)(input_tensor) # 有BN層就不需要偏置x = layers.BatchNormalization()(x) # 批標準化x = layers.ReLU()(x) # relu激活函數(shù)return x # 返回標準卷積的輸出特征圖
(2)殘差塊
按結(jié)構(gòu)圖所示,構(gòu)建一個殘差單元,由 兩個深度可分離卷積+最大池化+殘差邊 組成
#(2)深度可分離卷積模塊
def sep_conv_block(input_tensor, filters, kernel_size):# 激活函數(shù)x = layers.ReLU()(input_tensor)# 深度可分離卷積函數(shù),包含了(深度卷積+逐點卷積)x = layers.SeparableConvolution2D(filters = filters, # 逐點卷積的卷積核個數(shù),輸出特征圖個數(shù)kernel_size = kernel_size, # 深度卷積的卷積核sizestrides = 1, # 深度卷積的步長padding = 'same', # 卷積過程中特征圖size不變use_bias = False)(x) # 有BN層就不要偏置return x # 返回輸出特征圖#(3)一個殘差單元
def res_block(input_tensor, filters):# ① 殘差邊residual = layers.Conv2D(filters, # 輸出圖像的通道數(shù)kernel_size = (1,1), # 卷積核sizestrides = 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 完整代碼展示
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import Model, layers#(1)標準卷積模塊
def conv_block(input_tensor, filters, kernel_size, stride):# 普通卷積+標準化+激活函數(shù)x = layers.Conv2D(filters = filters, # 輸出特征圖個數(shù)kernel_size = kernel_size, # 卷積sizestrides = stride, # 步長padding = 'same', # 步長=1輸出特征圖size不變,步長=2特征圖長寬減半use_bias = False)(input_tensor) # 有BN層就不需要偏置x = layers.BatchNormalization()(x) # 批標準化x = layers.ReLU()(x) # relu激活函數(shù)return x # 返回標準卷積的輸出特征圖#(2)深度可分離卷積模塊
def sep_conv_block(input_tensor, filters, kernel_size):# 激活函數(shù)x = layers.ReLU()(input_tensor)# 深度可分離卷積函數(shù),包含了(深度卷積+逐點卷積)x = layers.SeparableConvolution2D(filters = filters, # 逐點卷積的卷積核個數(shù),輸出特征圖個數(shù)kernel_size = kernel_size, # 深度卷積的卷積核sizestrides = 1, # 深度卷積的步長padding = 'same', # 卷積過程中特征圖size不變use_bias = False)(x) # 有BN層就不要偏置return x # 返回輸出特征圖#(3)一個殘差單元
def res_block(input_tensor, filters):# ① 殘差邊residual = layers.Conv2D(filters, # 輸出圖像的通道數(shù)kernel_size = (1,1), # 卷積核sizestrides = 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):# 該模塊循環(huán)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)主干網(wǎng)絡(luò)
def xception(input_shape, classes):# 構(gòu)建輸入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# 構(gòu)建模型model = Model(inputs, outputs)return model#(6)接收網(wǎng)絡(luò)模型
if __name__ == '__main__':model = xception(input_shape=[299,299,3], classes=1000)model.summary() # 查看網(wǎng)絡(luò)模型結(jié)構(gòu)
3.4 查看網(wǎng)絡(luò)架構(gòu)
通過 model.summary() 查看網(wǎng)絡(luò)模型框架,網(wǎng)絡(luò)參數(shù)量2千多萬
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
__________________________________________________________________________________________________
總結(jié)
以上是生活随笔為你收集整理的【神经网络】(15) Xception 代码复现,网络解析,附Tensorflow完整代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【神经网络】(14) MnasNet 代
- 下一篇: 【深度学习理论】(1) 损失函数