概述
理论上讲,当网络层数加深时,网络的性能会变强,而实际上,在不断的加深网络层数后,分类性能不会提高,而是会导致网络收敛更缓慢,准确率也随着降低。利用数据增强等方法抑制过拟合后,准确率也不会得到提高,出现梯度消失的现象。因此,盲目的增加网络层数会适得其反,因此,ResNet(残差网络)系列网络出现了。本次基于Tensorflow2.0实现ResNet50网络。
1.ResNet50网络简介
ResNet50网络在层数上相比于VGG系列网络更胜一筹。这是何凯明在2015年提出的一种网络结构,获得了ILSVRC-2015分类任务的第一名,同时在ImageNet detection,ImageNet localization,COCO detection和COCO segmentation等任务中均获得了第一名,在当时可谓是轰动一时。
2.网络结构
主要分为4个模块,但是每个模块中主要包括两个最基本的块。
3.创新点
1.引入残差网络(跳跃连接)
这个残差结构实际上就是一个差分方放大器,使得映射F(x)对输出的变化更加敏感。这个结构不仅改善了网络越深越难训练的缺点还加快了模型的收敛速度。(这样做为什么能够实现这样的效果)跳跃链接如下所示:
ResNet50网络主要采用如下两个模块:
①左图为基本的residual block,residual mapping为两个64通道的3x3卷积,输入输出均为64通道,可直接相加。该block主要使用在相对浅层网络。
② 右图为针对深层网络提出的block,称为“bottleneck” block,主要目的就是为了降维。首先通过一个1x1卷积将256维通道(channel)降到64通道,最后通过一个256通道的1x1卷积恢复。
2.使用1x1卷积核
1x1卷积核在ResNet50网络中,主要用于升维和降维。这也是一个创新点。
3.使用全局平均池化
在VGG系列中,参数大部分出在了全连接层,而在ResNet网络中,去除全连接层,而是用全局平均池化代替,大大减少了参数数量,加快了运算速度。
4.网络实现
def identity_block(input_ten,kernel_size,filters):
filters1,filters2,filters3 = filters
x = Conv2D(filters1,(1,1))(input_ten)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Conv2D(filters2,kernel_size,padding='same')(x)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Conv2D(filters3,(1,1))(x)
x = BatchNormalization()(x)
x = layers.add([x,input_ten])
x = Activation('relu')(x)
return x
def conv_block(input_ten,kernel_size,filters,strides=(2,2)):
filters1,filters2,filters3 = filters
x = Conv2D(filters1,(1,1),strides=strides)(input_ten)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Conv2D(filters2,kernel_size,padding='same')(x)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Conv2D(filters3,(1,1))(x)
x = BatchNormalization()(x)
shortcut = Conv2D(filters3,(1,1),strides=strides)(input_ten)
shortcut = BatchNormalization()(shortcut)
x = layers.add([x,shortcut])
x = Activation('relu')(x)
return x
def ResNet50(nb_class,input_shape):
input_ten = Input(shape=input_shape)
x = ZeroPadding2D((3,3))(input_ten)
x = Conv2D(64,(7,7),strides=(2,2))(x)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = MaxPooling2D((3,3),strides=(2,2))(x)
x = conv_block(x,3,[64,64,256],strides=(1,1))
x = identity_block(x,3,[64,64,256])
x = identity_block(x,3,[64,64,256])
x = conv_block(x,3,[128,128,512])
x = identity_block(x,3,[128,128,512])
x = identity_block(x,3,[128,128,512])
x = identity_block(x,3,[128,128,512])
x = conv_block(x,3,[256,256,1024])
x = identity_block(x,3,[256,256,1024])
x = identity_block(x,3,[256,256,1024])
x = identity_block(x,3,[256,256,1024])
x = identity_block(x,3,[256,256,1024])
x = identity_block(x,3,[256,256,1024])
x = conv_block(x,3,[512,512,2048])
x = identity_block(x,3,[512,512,2048])
x = identity_block(x,3,[512,512,2048])
x = AveragePooling2D((7,7))(x)
x = tf.keras.layers.Flatten()(x)
output_ten = Dense(nb_class,activation='softmax')(x)
model = Model(input_ten,output_ten)
model.load_weights("resnet50_weights_tf_dim_ordering_tf_kernels.h5")
return model
model_ResNet50 = ResNet50(24,(img_height,img_width,3))
model_ResNet50.summary()
Model: "model_2"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_3 (InputLayer) [(None, 224, 224, 3) 0
__________________________________________________________________________________________________
zero_padding2d_1 (ZeroPadding2D (None, 230, 230, 3) 0 input_3[0][0]
__________________________________________________________________________________________________
conv2d_66 (Conv2D) (None, 112, 112, 64) 9472 zero_padding2d_1[0][0]
__________________________________________________________________________________________________
batch_normalization_53 (BatchNo (None, 112, 112, 64) 256 conv2d_66[0][0]
__________________________________________________________________________________________________
activation_49 (Activation) (None, 112, 112, 64) 0 batch_normalization_53[0][0]
__________________________________________________________________________________________________
max_pooling2d_6 (MaxPooling2D) (None, 55, 55, 64) 0 activation_49[0][0]
__________________________________________________________________________________________________
conv2d_67 (Conv2D) (None, 55, 55, 64) 4160 max_pooling2d_6[0][0]
__________________________________________________________________________________________________
batch_normalization_54 (BatchNo (None, 55, 55, 64) 256 conv2d_67[0][0]
__________________________________________________________________________________________________
activation_50 (Activation) (None, 55, 55, 64) 0 batch_normalization_54[0][0]
__________________________________________________________________________________________________
conv2d_68 (Conv2D) (None, 55, 55, 64) 36928 activation_50[0][0]
__________________________________________________________________________________________________
batch_normalization_55 (BatchNo (None, 55, 55, 64) 256 conv2d_68[0][0]
__________________________________________________________________________________________________
activation_51 (Activation) (None, 55, 55, 64) 0 batch_normalization_55[0][0]
__________________________________________________________________________________________________
conv2d_69 (Conv2D) (None, 55, 55, 256) 16640 activation_51[0][0]
__________________________________________________________________________________________________
conv2d_70 (Conv2D) (None, 55, 55, 256) 16640 max_pooling2d_6[0][0]
__________________________________________________________________________________________________
batch_normalization_56 (BatchNo (None, 55, 55, 256) 1024 conv2d_69[0][0]
__________________________________________________________________________________________________
batch_normalization_57 (BatchNo (None, 55, 55, 256) 1024 conv2d_70[0][0]
__________________________________________________________________________________________________
add_16 (Add) (None, 55, 55, 256) 0 batch_normalization_56[0][0]
batch_normalization_57[0][0]
__________________________________________________________________________________________________
activation_52 (Activation) (None, 55, 55, 256) 0 add_16[0][0]
__________________________________________________________________________________________________
conv2d_71 (Conv2D) (None, 55, 55, 64) 16448 activation_52[0][0]
__________________________________________________________________________________________________
batch_normalization_58 (BatchNo (None, 55, 55, 64) 256 conv2d_71[0][0]
__________________________________________________________________________________________________
activation_53 (Activation) (None, 55, 55, 64) 0 batch_normalization_58[0][0]
__________________________________________________________________________________________________
conv2d_72 (Conv2D) (None, 55, 55, 64) 36928 activation_53[0][0]
__________________________________________________________________________________________________
batch_normalization_59 (BatchNo (None, 55, 55, 64) 256 conv2d_72[0][0]
__________________________________________________________________________________________________
activation_54 (Activation) (None, 55, 55, 64) 0 batch_normalization_59[0][0]
__________________________________________________________________________________________________
conv2d_73 (Conv2D) (None, 55, 55, 256) 16640 activation_54[0][0]
__________________________________________________________________________________________________
batch_normalization_60 (BatchNo (None, 55, 55, 256) 1024 conv2d_73[0][0]
__________________________________________________________________________________________________
add_17 (Add) (None, 55, 55, 256) 0 batch_normalization_60[0][0]
activation_52[0][0]
__________________________________________________________________________________________________
activation_55 (Activation) (None, 55, 55, 256) 0 add_17[0][0]
__________________________________________________________________________________________________
conv2d_74 (Conv2D) (None, 55, 55, 64) 16448 activation_55[0][0]
__________________________________________________________________________________________________
batch_normalization_61 (BatchNo (None, 55, 55, 64) 256 conv2d_74[0][0]
__________________________________________________________________________________________________
activation_56 (Activation) (None, 55, 55, 64) 0 batch_normalization_61[0][0]
__________________________________________________________________________________________________
conv2d_75 (Conv2D) (None, 55, 55, 64) 36928 activation_56[0][0]
__________________________________________________________________________________________________
batch_normalization_62 (BatchNo (None, 55, 55, 64) 256 conv2d_75[0][0]
__________________________________________________________________________________________________
activation_57 (Activation) (None, 55, 55, 64) 0 batch_normalization_62[0][0]
__________________________________________________________________________________________________
conv2d_76 (Conv2D) (None, 55, 55, 256) 16640 activation_57[0][0]
__________________________________________________________________________________________________
batch_normalization_63 (BatchNo (None, 55, 55, 256) 1024 conv2d_76[0][0]
__________________________________________________________________________________________________
add_18 (Add) (None, 55, 55, 256) 0 batch_normalization_63[0][0]
activation_55[0][0]
__________________________________________________________________________________________________
activation_58 (Activation) (None, 55, 55, 256) 0 add_18[0][0]
__________________________________________________________________________________________________
conv2d_77 (Conv2D) (None, 28, 28, 128) 32896 activation_58[0][0]
__________________________________________________________________________________________________
batch_normalization_64 (BatchNo (None, 28, 28, 128) 512 conv2d_77[0][0]
__________________________________________________________________________________________________
activation_59 (Activation) (None, 28, 28, 128) 0 batch_normalization_64[0][0]
__________________________________________________________________________________________________
conv2d_78 (Conv2D) (None, 28, 28, 128) 147584 activation_59[0][0]
__________________________________________________________________________________________________
batch_normalization_65 (BatchNo (None, 28, 28, 128) 512 conv2d_78[0][0]
__________________________________________________________________________________________________
activation_60 (Activation) (None, 28, 28, 128) 0 batch_normalization_65[0][0]
__________________________________________________________________________________________________
conv2d_79 (Conv2D) (None, 28, 28, 512) 66048 activation_60[0][0]
__________________________________________________________________________________________________
conv2d_80 (Conv2D) (None, 28, 28, 512) 131584 activation_58[0][0]
__________________________________________________________________________________________________
batch_normalization_66 (BatchNo (None, 28, 28, 512) 2048 conv2d_79[0][0]
__________________________________________________________________________________________________
batch_normalization_67 (BatchNo (None, 28, 28, 512) 2048 conv2d_80[0][0]
__________________________________________________________________________________________________
add_19 (Add) (None, 28, 28, 512) 0 batch_normalization_66[0][0]
batch_normalization_67[0][0]
__________________________________________________________________________________________________
activation_61 (Activation) (None, 28, 28, 512) 0 add_19[0][0]
__________________________________________________________________________________________________
conv2d_81 (Conv2D) (None, 28, 28, 128) 65664 activation_61[0][0]
__________________________________________________________________________________________________
batch_normalization_68 (BatchNo (None, 28, 28, 128) 512 conv2d_81[0][0]
__________________________________________________________________________________________________
activation_62 (Activation) (None, 28, 28, 128) 0 batch_normalization_68[0][0]
__________________________________________________________________________________________________
conv2d_82 (Conv2D) (None, 28, 28, 128) 147584 activation_62[0][0]
__________________________________________________________________________________________________
batch_normalization_69 (BatchNo (None, 28, 28, 128) 512 conv2d_82[0][0]
__________________________________________________________________________________________________
activation_63 (Activation) (None, 28, 28, 128) 0 batch_normalization_69[0][0]
__________________________________________________________________________________________________
conv2d_83 (Conv2D) (None, 28, 28, 512) 66048 activation_63[0][0]
__________________________________________________________________________________________________
batch_normalization_70 (BatchNo (None, 28, 28, 512) 2048 conv2d_83[0][0]
__________________________________________________________________________________________________
add_20 (Add) (None, 28, 28, 512) 0 batch_normalization_70[0][0]
activation_61[0][0]
__________________________________________________________________________________________________
activation_64 (Activation) (None, 28, 28, 512) 0 add_20[0][0]
__________________________________________________________________________________________________
conv2d_84 (Conv2D) (None, 28, 28, 128) 65664 activation_64[0][0]
__________________________________________________________________________________________________
batch_normalization_71 (BatchNo (None, 28, 28, 128) 512 conv2d_84[0][0]
__________________________________________________________________________________________________
activation_65 (Activation) (None, 28, 28, 128) 0 batch_normalization_71[0][0]
__________________________________________________________________________________________________
conv2d_85 (Conv2D) (None, 28, 28, 128) 147584 activation_65[0][0]
__________________________________________________________________________________________________
batch_normalization_72 (BatchNo (None, 28, 28, 128) 512 conv2d_85[0][0]
__________________________________________________________________________________________________
activation_66 (Activation) (None, 28, 28, 128) 0 batch_normalization_72[0][0]
__________________________________________________________________________________________________
conv2d_86 (Conv2D) (None, 28, 28, 512) 66048 activation_66[0][0]
__________________________________________________________________________________________________
batch_normalization_73 (BatchNo (None, 28, 28, 512) 2048 conv2d_86[0][0]
__________________________________________________________________________________________________
add_21 (Add) (None, 28, 28, 512) 0 batch_normalization_73[0][0]
activation_64[0][0]
__________________________________________________________________________________________________
activation_67 (Activation) (None, 28, 28, 512) 0 add_21[0][0]
__________________________________________________________________________________________________
conv2d_87 (Conv2D) (None, 28, 28, 128) 65664 activation_67[0][0]
__________________________________________________________________________________________________
batch_normalization_74 (BatchNo (None, 28, 28, 128) 512 conv2d_87[0][0]
__________________________________________________________________________________________________
activation_68 (Activation) (None, 28, 28, 128) 0 batch_normalization_74[0][0]
__________________________________________________________________________________________________
conv2d_88 (Conv2D) (None, 28, 28, 128) 147584 activation_68[0][0]
__________________________________________________________________________________________________
batch_normalization_75 (BatchNo (None, 28, 28, 128) 512 conv2d_88[0][0]
__________________________________________________________________________________________________
activation_69 (Activation) (None, 28, 28, 128) 0 batch_normalization_75[0][0]
__________________________________________________________________________________________________
conv2d_89 (Conv2D) (None, 28, 28, 512) 66048 activation_69[0][0]
__________________________________________________________________________________________________
batch_normalization_76 (BatchNo (None, 28, 28, 512) 2048 conv2d_89[0][0]
__________________________________________________________________________________________________
add_22 (Add) (None, 28, 28, 512) 0 batch_normalization_76[0][0]
activation_67[0][0]
__________________________________________________________________________________________________
activation_70 (Activation) (None, 28, 28, 512) 0 add_22[0][0]
__________________________________________________________________________________________________
conv2d_90 (Conv2D) (None, 14, 14, 256) 131328 activation_70[0][0]
__________________________________________________________________________________________________
batch_normalization_77 (BatchNo (None, 14, 14, 256) 1024 conv2d_90[0][0]
__________________________________________________________________________________________________
activation_71 (Activation) (None, 14, 14, 256) 0 batch_normalization_77[0][0]
__________________________________________________________________________________________________
conv2d_91 (Conv2D) (None, 14, 14, 256) 590080 activation_71[0][0]
__________________________________________________________________________________________________
batch_normalization_78 (BatchNo (None, 14, 14, 256) 1024 conv2d_91[0][0]
__________________________________________________________________________________________________
activation_72 (Activation) (None, 14, 14, 256) 0 batch_normalization_78[0][0]
__________________________________________________________________________________________________
conv2d_92 (Conv2D) (None, 14, 14, 1024) 263168 activation_72[0][0]
__________________________________________________________________________________________________
conv2d_93 (Conv2D) (None, 14, 14, 1024) 525312 activation_70[0][0]
__________________________________________________________________________________________________
batch_normalization_79 (BatchNo (None, 14, 14, 1024) 4096 conv2d_92[0][0]
__________________________________________________________________________________________________
batch_normalization_80 (BatchNo (None, 14, 14, 1024) 4096 conv2d_93[0][0]
__________________________________________________________________________________________________
add_23 (Add) (None, 14, 14, 1024) 0 batch_normalization_79[0][0]
batch_normalization_80[0][0]
__________________________________________________________________________________________________
activation_73 (Activation) (None, 14, 14, 1024) 0 add_23[0][0]
__________________________________________________________________________________________________
conv2d_94 (Conv2D) (None, 14, 14, 256) 262400 activation_73[0][0]
__________________________________________________________________________________________________
batch_normalization_81 (BatchNo (None, 14, 14, 256) 1024 conv2d_94[0][0]
__________________________________________________________________________________________________
activation_74 (Activation) (None, 14, 14, 256) 0 batch_normalization_81[0][0]
__________________________________________________________________________________________________
conv2d_95 (Conv2D) (None, 14, 14, 256) 590080 activation_74[0][0]
__________________________________________________________________________________________________
batch_normalization_82 (BatchNo (None, 14, 14, 256) 1024 conv2d_95[0][0]
__________________________________________________________________________________________________
activation_75 (Activation) (None, 14, 14, 256) 0 batch_normalization_82[0][0]
__________________________________________________________________________________________________
conv2d_96 (Conv2D) (None, 14, 14, 1024) 263168 activation_75[0][0]
__________________________________________________________________________________________________
batch_normalization_83 (BatchNo (None, 14, 14, 1024) 4096 conv2d_96[0][0]
__________________________________________________________________________________________________
add_24 (Add) (None, 14, 14, 1024) 0 batch_normalization_83[0][0]
activation_73[0][0]
__________________________________________________________________________________________________
activation_76 (Activation) (None, 14, 14, 1024) 0 add_24[0][0]
__________________________________________________________________________________________________
conv2d_97 (Conv2D) (None, 14, 14, 256) 262400 activation_76[0][0]
__________________________________________________________________________________________________
batch_normalization_84 (BatchNo (None, 14, 14, 256) 1024 conv2d_97[0][0]
__________________________________________________________________________________________________
activation_77 (Activation) (None, 14, 14, 256) 0 batch_normalization_84[0][0]
__________________________________________________________________________________________________
conv2d_98 (Conv2D) (None, 14, 14, 256) 590080 activation_77[0][0]
__________________________________________________________________________________________________
batch_normalization_85 (BatchNo (None, 14, 14, 256) 1024 conv2d_98[0][0]
__________________________________________________________________________________________________
activation_78 (Activation) (None, 14, 14, 256) 0 batch_normalization_85[0][0]
__________________________________________________________________________________________________
conv2d_99 (Conv2D) (None, 14, 14, 1024) 263168 activation_78[0][0]
__________________________________________________________________________________________________
batch_normalization_86 (BatchNo (None, 14, 14, 1024) 4096 conv2d_99[0][0]
__________________________________________________________________________________________________
add_25 (Add) (None, 14, 14, 1024) 0 batch_normalization_86[0][0]
activation_76[0][0]
__________________________________________________________________________________________________
activation_79 (Activation) (None, 14, 14, 1024) 0 add_25[0][0]
__________________________________________________________________________________________________
conv2d_100 (Conv2D) (None, 14, 14, 256) 262400 activation_79[0][0]
__________________________________________________________________________________________________
batch_normalization_87 (BatchNo (None, 14, 14, 256) 1024 conv2d_100[0][0]
__________________________________________________________________________________________________
activation_80 (Activation) (None, 14, 14, 256) 0 batch_normalization_87[0][0]
__________________________________________________________________________________________________
conv2d_101 (Conv2D) (None, 14, 14, 256) 590080 activation_80[0][0]
__________________________________________________________________________________________________
batch_normalization_88 (BatchNo (None, 14, 14, 256) 1024 conv2d_101[0][0]
__________________________________________________________________________________________________
activation_81 (Activation) (None, 14, 14, 256) 0 batch_normalization_88[0][0]
__________________________________________________________________________________________________
conv2d_102 (Conv2D) (None, 14, 14, 1024) 263168 activation_81[0][0]
__________________________________________________________________________________________________
batch_normalization_89 (BatchNo (None, 14, 14, 1024) 4096 conv2d_102[0][0]
__________________________________________________________________________________________________
add_26 (Add) (None, 14, 14, 1024) 0 batch_normalization_89[0][0]
activation_79[0][0]
__________________________________________________________________________________________________
activation_82 (Activation) (None, 14, 14, 1024) 0 add_26[0][0]
__________________________________________________________________________________________________
conv2d_103 (Conv2D) (None, 14, 14, 256) 262400 activation_82[0][0]
__________________________________________________________________________________________________
batch_normalization_90 (BatchNo (None, 14, 14, 256) 1024 conv2d_103[0][0]
__________________________________________________________________________________________________
activation_83 (Activation) (None, 14, 14, 256) 0 batch_normalization_90[0][0]
__________________________________________________________________________________________________
conv2d_104 (Conv2D) (None, 14, 14, 256) 590080 activation_83[0][0]
__________________________________________________________________________________________________
batch_normalization_91 (BatchNo (None, 14, 14, 256) 1024 conv2d_104[0][0]
__________________________________________________________________________________________________
activation_84 (Activation) (None, 14, 14, 256) 0 batch_normalization_91[0][0]
__________________________________________________________________________________________________
conv2d_105 (Conv2D) (None, 14, 14, 1024) 263168 activation_84[0][0]
__________________________________________________________________________________________________
batch_normalization_92 (BatchNo (None, 14, 14, 1024) 4096 conv2d_105[0][0]
__________________________________________________________________________________________________
add_27 (Add) (None, 14, 14, 1024) 0 batch_normalization_92[0][0]
activation_82[0][0]
__________________________________________________________________________________________________
activation_85 (Activation) (None, 14, 14, 1024) 0 add_27[0][0]
__________________________________________________________________________________________________
conv2d_106 (Conv2D) (None, 14, 14, 256) 262400 activation_85[0][0]
__________________________________________________________________________________________________
batch_normalization_93 (BatchNo (None, 14, 14, 256) 1024 conv2d_106[0][0]
__________________________________________________________________________________________________
activation_86 (Activation) (None, 14, 14, 256) 0 batch_normalization_93[0][0]
__________________________________________________________________________________________________
conv2d_107 (Conv2D) (None, 14, 14, 256) 590080 activation_86[0][0]
__________________________________________________________________________________________________
batch_normalization_94 (BatchNo (None, 14, 14, 256) 1024 conv2d_107[0][0]
__________________________________________________________________________________________________
activation_87 (Activation) (None, 14, 14, 256) 0 batch_normalization_94[0][0]
__________________________________________________________________________________________________
conv2d_108 (Conv2D) (None, 14, 14, 1024) 263168 activation_87[0][0]
__________________________________________________________________________________________________
batch_normalization_95 (BatchNo (None, 14, 14, 1024) 4096 conv2d_108[0][0]
__________________________________________________________________________________________________
add_28 (Add) (None, 14, 14, 1024) 0 batch_normalization_95[0][0]
activation_85[0][0]
__________________________________________________________________________________________________
activation_88 (Activation) (None, 14, 14, 1024) 0 add_28[0][0]
__________________________________________________________________________________________________
conv2d_109 (Conv2D) (None, 7, 7, 512) 524800 activation_88[0][0]
__________________________________________________________________________________________________
batch_normalization_96 (BatchNo (None, 7, 7, 512) 2048 conv2d_109[0][0]
__________________________________________________________________________________________________
activation_89 (Activation) (None, 7, 7, 512) 0 batch_normalization_96[0][0]
__________________________________________________________________________________________________
conv2d_110 (Conv2D) (None, 7, 7, 512) 2359808 activation_89[0][0]
__________________________________________________________________________________________________
batch_normalization_97 (BatchNo (None, 7, 7, 512) 2048 conv2d_110[0][0]
__________________________________________________________________________________________________
activation_90 (Activation) (None, 7, 7, 512) 0 batch_normalization_97[0][0]
__________________________________________________________________________________________________
conv2d_111 (Conv2D) (None, 7, 7, 2048) 1050624 activation_90[0][0]
__________________________________________________________________________________________________
conv2d_112 (Conv2D) (None, 7, 7, 2048) 2099200 activation_88[0][0]
__________________________________________________________________________________________________
batch_normalization_98 (BatchNo (None, 7, 7, 2048) 8192 conv2d_111[0][0]
__________________________________________________________________________________________________
batch_normalization_99 (BatchNo (None, 7, 7, 2048) 8192 conv2d_112[0][0]
__________________________________________________________________________________________________
add_29 (Add) (None, 7, 7, 2048) 0 batch_normalization_98[0][0]
batch_normalization_99[0][0]
__________________________________________________________________________________________________
activation_91 (Activation) (None, 7, 7, 2048) 0 add_29[0][0]
__________________________________________________________________________________________________
conv2d_113 (Conv2D) (None, 7, 7, 512) 1049088 activation_91[0][0]
__________________________________________________________________________________________________
batch_normalization_100 (BatchN (None, 7, 7, 512) 2048 conv2d_113[0][0]
__________________________________________________________________________________________________
activation_92 (Activation) (None, 7, 7, 512) 0 batch_normalization_100[0][0]
__________________________________________________________________________________________________
conv2d_114 (Conv2D) (None, 7, 7, 512) 2359808 activation_92[0][0]
__________________________________________________________________________________________________
batch_normalization_101 (BatchN (None, 7, 7, 512) 2048 conv2d_114[0][0]
__________________________________________________________________________________________________
activation_93 (Activation) (None, 7, 7, 512) 0 batch_normalization_101[0][0]
__________________________________________________________________________________________________
conv2d_115 (Conv2D) (None, 7, 7, 2048) 1050624 activation_93[0][0]
__________________________________________________________________________________________________
batch_normalization_102 (BatchN (None, 7, 7, 2048) 8192 conv2d_115[0][0]
__________________________________________________________________________________________________
add_30 (Add) (None, 7, 7, 2048) 0 batch_normalization_102[0][0]
activation_91[0][0]
__________________________________________________________________________________________________
activation_94 (Activation) (None, 7, 7, 2048) 0 add_30[0][0]
__________________________________________________________________________________________________
conv2d_116 (Conv2D) (None, 7, 7, 512) 1049088 activation_94[0][0]
__________________________________________________________________________________________________
batch_normalization_103 (BatchN (None, 7, 7, 512) 2048 conv2d_116[0][0]
__________________________________________________________________________________________________
activation_95 (Activation) (None, 7, 7, 512) 0 batch_normalization_103[0][0]
__________________________________________________________________________________________________
conv2d_117 (Conv2D) (None, 7, 7, 512) 2359808 activation_95[0][0]
__________________________________________________________________________________________________
batch_normalization_104 (BatchN (None, 7, 7, 512) 2048 conv2d_117[0][0]
__________________________________________________________________________________________________
activation_96 (Activation) (None, 7, 7, 512) 0 batch_normalization_104[0][0]
__________________________________________________________________________________________________
conv2d_118 (Conv2D) (None, 7, 7, 2048) 1050624 activation_96[0][0]
__________________________________________________________________________________________________
batch_normalization_105 (BatchN (None, 7, 7, 2048) 8192 conv2d_118[0][0]
__________________________________________________________________________________________________
add_31 (Add) (None, 7, 7, 2048) 0 batch_normalization_105[0][0]
activation_94[0][0]
__________________________________________________________________________________________________
activation_97 (Activation) (None, 7, 7, 2048) 0 add_31[0][0]
__________________________________________________________________________________________________
average_pooling2d_1 (AveragePoo (None, 1, 1, 2048) 0 activation_97[0][0]
__________________________________________________________________________________________________
flatten_2 (Flatten) (None, 2048) 0 average_pooling2d_1[0][0]
__________________________________________________________________________________________________
dense_4 (Dense) (None, 24) 49176 flatten_2[0][0]
==================================================================================================
Total params: 23,636,888
Trainable params: 23,583,768
Non-trainable params: 53,120
__________________________________________________________________________________________________
相比于VGG16网络,虽然层数加深,但是训练参数却大大减少,甚至比AlexNet网络还少。得益于去除全连接层,而是用全局平均池化。
努力加油a啊
最后
以上就是自由老鼠为你收集整理的深度学习之基于Tensorflow2.0实现ResNet50网络的全部内容,希望文章能够帮你解决深度学习之基于Tensorflow2.0实现ResNet50网络所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复