keras 的 example 文件 class_activation_maps.py 解析

该文件功能是实现一个CNN可视化,我不知道这个叫法算不算专业,可以参考别人写的文章

https://zhuanlan.zhihu.com/p/51631163

https://blog.csdn.net/weixin_40955254/article/details/81191896

应该就是看下神经网络是通过关注哪部分区域预测出的最终结果

 

其基础网络是resnet50,get_cam_model函数中对其进行了一点修改,可参考下图,看到修改了哪些地方

keras 的 example 文件 class_activation_maps.py 解析_第1张图片

就是仅添加了两层神经网络,其他没有动

预测后通过postprocess函数提取出感兴趣的那个分类的channel,我把该函数简化了一下,应该更容易理解一点

def postprocess(preds, cams, top_k=1):
    idxes = np.argsort(preds[0])[-top_k:][0]
    return cams[0, :, :, idxes]

文件最后的代码,我作了如下修改:

# 5. plot image+cam to original size
# plt.imshow(original_img, alpha=0.5)
plt.imshow(cv2.resize(class_activation_map,
                      original_size), cmap='jet')
plt.savefig("res.jpg")
plt.show()

看下效果图

原图

keras 的 example 文件 class_activation_maps.py 解析_第2张图片

预测后结果的颜色图谱

keras 的 example 文件 class_activation_maps.py 解析_第3张图片

也就是说,他是根据这部分区域预测出的结果,这是一只金毛犬,下面可以把分类名称打印出来

from keras.applications.imagenet_utils import decode_predictions
print(decode_predictions(preds))
[[('n02099601', 'golden_retriever', 0.82736635), ('n02111129', 'Leonberg', 0.08901908), ('n02111277', 'Newfoundland', 0.008406928), ('n02104029', 'kuvasz', 0.007829149), ('n02099712', 'Labrador_retriever', 0.004909024)]]

如果最后面代码没有修改的话,显示结果为:

keras 的 example 文件 class_activation_maps.py 解析_第4张图片

就是和原图进行了一个叠加,显示出,哪部分区域,是CNN得出最终预测结果的主要依据

——————————————————

下面是自己折腾时刻,不属于正文

如果我把图片旋转一下,发现resnet几乎无法识别了

[[('n02099601', 'golden_retriever', 0.2694396), ('n02113023', 'Pembroke', 0.16751677), ('n01514859', 'hen', 0.10281576), ('n02105251', 'briard', 0.03323859), ('n02102318', 'cocker_spaniel', 0.03284181)]]

keras 的 example 文件 class_activation_maps.py 解析_第5张图片

 

当然,如果水平翻转,还是能识别到的,而且关注点也可以正确的找到

[[('n02099601', 'golden_retriever', 0.82862425), ('n02111129', 'Leonberg', 0.07444748), ('n02104029', 'kuvasz', 0.01596525), ('n02111277', 'Newfoundland', 0.015939327), ('n02099267', 'flat-coated_retriever', 0.0076823044)]]

keras 的 example 文件 class_activation_maps.py 解析_第6张图片

附修改后的神经网络

________________________________________________________________________________________________________________________
Layer (type)                           Output Shape               Param #       Connected to
========================================================================================================================
input_1 (InputLayer)                   (None, 224, 224, 3)        0
________________________________________________________________________________________________________________________
conv1_pad (ZeroPadding2D)              (None, 230, 230, 3)        0             input_1[0][0]
________________________________________________________________________________________________________________________
conv1 (Conv2D)                         (None, 112, 112, 64)       9472          conv1_pad[0][0]
________________________________________________________________________________________________________________________
bn_conv1 (BatchNormalization)          (None, 112, 112, 64)       256           conv1[0][0]
________________________________________________________________________________________________________________________
activation_1 (Activation)              (None, 112, 112, 64)       0             bn_conv1[0][0]
________________________________________________________________________________________________________________________
pool1_pad (ZeroPadding2D)              (None, 114, 114, 64)       0             activation_1[0][0]
________________________________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D)         (None, 56, 56, 64)         0             pool1_pad[0][0]
________________________________________________________________________________________________________________________
res2a_branch2a (Conv2D)                (None, 56, 56, 64)         4160          max_pooling2d_1[0][0]
________________________________________________________________________________________________________________________
bn2a_branch2a (BatchNormalization)     (None, 56, 56, 64)         256           res2a_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_2 (Activation)              (None, 56, 56, 64)         0             bn2a_branch2a[0][0]
________________________________________________________________________________________________________________________
res2a_branch2b (Conv2D)                (None, 56, 56, 64)         36928         activation_2[0][0]
________________________________________________________________________________________________________________________
bn2a_branch2b (BatchNormalization)     (None, 56, 56, 64)         256           res2a_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_3 (Activation)              (None, 56, 56, 64)         0             bn2a_branch2b[0][0]
________________________________________________________________________________________________________________________
res2a_branch2c (Conv2D)                (None, 56, 56, 256)        16640         activation_3[0][0]
________________________________________________________________________________________________________________________
res2a_branch1 (Conv2D)                 (None, 56, 56, 256)        16640         max_pooling2d_1[0][0]
________________________________________________________________________________________________________________________
bn2a_branch2c (BatchNormalization)     (None, 56, 56, 256)        1024          res2a_branch2c[0][0]
________________________________________________________________________________________________________________________
bn2a_branch1 (BatchNormalization)      (None, 56, 56, 256)        1024          res2a_branch1[0][0]
________________________________________________________________________________________________________________________
add_1 (Add)                            (None, 56, 56, 256)        0             bn2a_branch2c[0][0]
                                                                                bn2a_branch1[0][0]
________________________________________________________________________________________________________________________
activation_4 (Activation)              (None, 56, 56, 256)        0             add_1[0][0]
________________________________________________________________________________________________________________________
res2b_branch2a (Conv2D)                (None, 56, 56, 64)         16448         activation_4[0][0]
________________________________________________________________________________________________________________________
bn2b_branch2a (BatchNormalization)     (None, 56, 56, 64)         256           res2b_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_5 (Activation)              (None, 56, 56, 64)         0             bn2b_branch2a[0][0]
________________________________________________________________________________________________________________________
res2b_branch2b (Conv2D)                (None, 56, 56, 64)         36928         activation_5[0][0]
________________________________________________________________________________________________________________________
bn2b_branch2b (BatchNormalization)     (None, 56, 56, 64)         256           res2b_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_6 (Activation)              (None, 56, 56, 64)         0             bn2b_branch2b[0][0]
________________________________________________________________________________________________________________________
res2b_branch2c (Conv2D)                (None, 56, 56, 256)        16640         activation_6[0][0]
________________________________________________________________________________________________________________________
bn2b_branch2c (BatchNormalization)     (None, 56, 56, 256)        1024          res2b_branch2c[0][0]
________________________________________________________________________________________________________________________
add_2 (Add)                            (None, 56, 56, 256)        0             bn2b_branch2c[0][0]
                                                                                activation_4[0][0]
________________________________________________________________________________________________________________________
activation_7 (Activation)              (None, 56, 56, 256)        0             add_2[0][0]
________________________________________________________________________________________________________________________
res2c_branch2a (Conv2D)                (None, 56, 56, 64)         16448         activation_7[0][0]
________________________________________________________________________________________________________________________
bn2c_branch2a (BatchNormalization)     (None, 56, 56, 64)         256           res2c_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_8 (Activation)              (None, 56, 56, 64)         0             bn2c_branch2a[0][0]
________________________________________________________________________________________________________________________
res2c_branch2b (Conv2D)                (None, 56, 56, 64)         36928         activation_8[0][0]
________________________________________________________________________________________________________________________
bn2c_branch2b (BatchNormalization)     (None, 56, 56, 64)         256           res2c_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_9 (Activation)              (None, 56, 56, 64)         0             bn2c_branch2b[0][0]
________________________________________________________________________________________________________________________
res2c_branch2c (Conv2D)                (None, 56, 56, 256)        16640         activation_9[0][0]
________________________________________________________________________________________________________________________
bn2c_branch2c (BatchNormalization)     (None, 56, 56, 256)        1024          res2c_branch2c[0][0]
________________________________________________________________________________________________________________________
add_3 (Add)                            (None, 56, 56, 256)        0             bn2c_branch2c[0][0]
                                                                                activation_7[0][0]
________________________________________________________________________________________________________________________
activation_10 (Activation)             (None, 56, 56, 256)        0             add_3[0][0]
________________________________________________________________________________________________________________________
res3a_branch2a (Conv2D)                (None, 28, 28, 128)        32896         activation_10[0][0]
________________________________________________________________________________________________________________________
bn3a_branch2a (BatchNormalization)     (None, 28, 28, 128)        512           res3a_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_11 (Activation)             (None, 28, 28, 128)        0             bn3a_branch2a[0][0]
________________________________________________________________________________________________________________________
res3a_branch2b (Conv2D)                (None, 28, 28, 128)        147584        activation_11[0][0]
________________________________________________________________________________________________________________________
bn3a_branch2b (BatchNormalization)     (None, 28, 28, 128)        512           res3a_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_12 (Activation)             (None, 28, 28, 128)        0             bn3a_branch2b[0][0]
________________________________________________________________________________________________________________________
res3a_branch2c (Conv2D)                (None, 28, 28, 512)        66048         activation_12[0][0]
________________________________________________________________________________________________________________________
res3a_branch1 (Conv2D)                 (None, 28, 28, 512)        131584        activation_10[0][0]
________________________________________________________________________________________________________________________
bn3a_branch2c (BatchNormalization)     (None, 28, 28, 512)        2048          res3a_branch2c[0][0]
________________________________________________________________________________________________________________________
bn3a_branch1 (BatchNormalization)      (None, 28, 28, 512)        2048          res3a_branch1[0][0]
________________________________________________________________________________________________________________________
add_4 (Add)                            (None, 28, 28, 512)        0             bn3a_branch2c[0][0]
                                                                                bn3a_branch1[0][0]
________________________________________________________________________________________________________________________
activation_13 (Activation)             (None, 28, 28, 512)        0             add_4[0][0]
________________________________________________________________________________________________________________________
res3b_branch2a (Conv2D)                (None, 28, 28, 128)        65664         activation_13[0][0]
________________________________________________________________________________________________________________________
bn3b_branch2a (BatchNormalization)     (None, 28, 28, 128)        512           res3b_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_14 (Activation)             (None, 28, 28, 128)        0             bn3b_branch2a[0][0]
________________________________________________________________________________________________________________________
res3b_branch2b (Conv2D)                (None, 28, 28, 128)        147584        activation_14[0][0]
________________________________________________________________________________________________________________________
bn3b_branch2b (BatchNormalization)     (None, 28, 28, 128)        512           res3b_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_15 (Activation)             (None, 28, 28, 128)        0             bn3b_branch2b[0][0]
________________________________________________________________________________________________________________________
res3b_branch2c (Conv2D)                (None, 28, 28, 512)        66048         activation_15[0][0]
________________________________________________________________________________________________________________________
bn3b_branch2c (BatchNormalization)     (None, 28, 28, 512)        2048          res3b_branch2c[0][0]
________________________________________________________________________________________________________________________
add_5 (Add)                            (None, 28, 28, 512)        0             bn3b_branch2c[0][0]
                                                                                activation_13[0][0]
________________________________________________________________________________________________________________________
activation_16 (Activation)             (None, 28, 28, 512)        0             add_5[0][0]
________________________________________________________________________________________________________________________
res3c_branch2a (Conv2D)                (None, 28, 28, 128)        65664         activation_16[0][0]
________________________________________________________________________________________________________________________
bn3c_branch2a (BatchNormalization)     (None, 28, 28, 128)        512           res3c_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_17 (Activation)             (None, 28, 28, 128)        0             bn3c_branch2a[0][0]
________________________________________________________________________________________________________________________
res3c_branch2b (Conv2D)                (None, 28, 28, 128)        147584        activation_17[0][0]
________________________________________________________________________________________________________________________
bn3c_branch2b (BatchNormalization)     (None, 28, 28, 128)        512           res3c_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_18 (Activation)             (None, 28, 28, 128)        0             bn3c_branch2b[0][0]
________________________________________________________________________________________________________________________
res3c_branch2c (Conv2D)                (None, 28, 28, 512)        66048         activation_18[0][0]
________________________________________________________________________________________________________________________
bn3c_branch2c (BatchNormalization)     (None, 28, 28, 512)        2048          res3c_branch2c[0][0]
________________________________________________________________________________________________________________________
add_6 (Add)                            (None, 28, 28, 512)        0             bn3c_branch2c[0][0]
                                                                                activation_16[0][0]
________________________________________________________________________________________________________________________
activation_19 (Activation)             (None, 28, 28, 512)        0             add_6[0][0]
________________________________________________________________________________________________________________________
res3d_branch2a (Conv2D)                (None, 28, 28, 128)        65664         activation_19[0][0]
________________________________________________________________________________________________________________________
bn3d_branch2a (BatchNormalization)     (None, 28, 28, 128)        512           res3d_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_20 (Activation)             (None, 28, 28, 128)        0             bn3d_branch2a[0][0]
________________________________________________________________________________________________________________________
res3d_branch2b (Conv2D)                (None, 28, 28, 128)        147584        activation_20[0][0]
________________________________________________________________________________________________________________________
bn3d_branch2b (BatchNormalization)     (None, 28, 28, 128)        512           res3d_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_21 (Activation)             (None, 28, 28, 128)        0             bn3d_branch2b[0][0]
________________________________________________________________________________________________________________________
res3d_branch2c (Conv2D)                (None, 28, 28, 512)        66048         activation_21[0][0]
________________________________________________________________________________________________________________________
bn3d_branch2c (BatchNormalization)     (None, 28, 28, 512)        2048          res3d_branch2c[0][0]
________________________________________________________________________________________________________________________
add_7 (Add)                            (None, 28, 28, 512)        0             bn3d_branch2c[0][0]
                                                                                activation_19[0][0]
________________________________________________________________________________________________________________________
activation_22 (Activation)             (None, 28, 28, 512)        0             add_7[0][0]
________________________________________________________________________________________________________________________
res4a_branch2a (Conv2D)                (None, 14, 14, 256)        131328        activation_22[0][0]
________________________________________________________________________________________________________________________
bn4a_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4a_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_23 (Activation)             (None, 14, 14, 256)        0             bn4a_branch2a[0][0]
________________________________________________________________________________________________________________________
res4a_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_23[0][0]
________________________________________________________________________________________________________________________
bn4a_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4a_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_24 (Activation)             (None, 14, 14, 256)        0             bn4a_branch2b[0][0]
________________________________________________________________________________________________________________________
res4a_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_24[0][0]
________________________________________________________________________________________________________________________
res4a_branch1 (Conv2D)                 (None, 14, 14, 1024)       525312        activation_22[0][0]
________________________________________________________________________________________________________________________
bn4a_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4a_branch2c[0][0]
________________________________________________________________________________________________________________________
bn4a_branch1 (BatchNormalization)      (None, 14, 14, 1024)       4096          res4a_branch1[0][0]
________________________________________________________________________________________________________________________
add_8 (Add)                            (None, 14, 14, 1024)       0             bn4a_branch2c[0][0]
                                                                                bn4a_branch1[0][0]
________________________________________________________________________________________________________________________
activation_25 (Activation)             (None, 14, 14, 1024)       0             add_8[0][0]
________________________________________________________________________________________________________________________
res4b_branch2a (Conv2D)                (None, 14, 14, 256)        262400        activation_25[0][0]
________________________________________________________________________________________________________________________
bn4b_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4b_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_26 (Activation)             (None, 14, 14, 256)        0             bn4b_branch2a[0][0]
________________________________________________________________________________________________________________________
res4b_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_26[0][0]
________________________________________________________________________________________________________________________
bn4b_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4b_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_27 (Activation)             (None, 14, 14, 256)        0             bn4b_branch2b[0][0]
________________________________________________________________________________________________________________________
res4b_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_27[0][0]
________________________________________________________________________________________________________________________
bn4b_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4b_branch2c[0][0]
________________________________________________________________________________________________________________________
add_9 (Add)                            (None, 14, 14, 1024)       0             bn4b_branch2c[0][0]
                                                                                activation_25[0][0]
________________________________________________________________________________________________________________________
activation_28 (Activation)             (None, 14, 14, 1024)       0             add_9[0][0]
________________________________________________________________________________________________________________________
res4c_branch2a (Conv2D)                (None, 14, 14, 256)        262400        activation_28[0][0]
________________________________________________________________________________________________________________________
bn4c_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4c_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_29 (Activation)             (None, 14, 14, 256)        0             bn4c_branch2a[0][0]
________________________________________________________________________________________________________________________
res4c_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_29[0][0]
________________________________________________________________________________________________________________________
bn4c_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4c_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_30 (Activation)             (None, 14, 14, 256)        0             bn4c_branch2b[0][0]
________________________________________________________________________________________________________________________
res4c_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_30[0][0]
________________________________________________________________________________________________________________________
bn4c_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4c_branch2c[0][0]
________________________________________________________________________________________________________________________
add_10 (Add)                           (None, 14, 14, 1024)       0             bn4c_branch2c[0][0]
                                                                                activation_28[0][0]
________________________________________________________________________________________________________________________
activation_31 (Activation)             (None, 14, 14, 1024)       0             add_10[0][0]
________________________________________________________________________________________________________________________
res4d_branch2a (Conv2D)                (None, 14, 14, 256)        262400        activation_31[0][0]
________________________________________________________________________________________________________________________
bn4d_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4d_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_32 (Activation)             (None, 14, 14, 256)        0             bn4d_branch2a[0][0]
________________________________________________________________________________________________________________________
res4d_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_32[0][0]
________________________________________________________________________________________________________________________
bn4d_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4d_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_33 (Activation)             (None, 14, 14, 256)        0             bn4d_branch2b[0][0]
________________________________________________________________________________________________________________________
res4d_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_33[0][0]
________________________________________________________________________________________________________________________
bn4d_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4d_branch2c[0][0]
________________________________________________________________________________________________________________________
add_11 (Add)                           (None, 14, 14, 1024)       0             bn4d_branch2c[0][0]
                                                                                activation_31[0][0]
________________________________________________________________________________________________________________________
activation_34 (Activation)             (None, 14, 14, 1024)       0             add_11[0][0]
________________________________________________________________________________________________________________________
res4e_branch2a (Conv2D)                (None, 14, 14, 256)        262400        activation_34[0][0]
________________________________________________________________________________________________________________________
bn4e_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4e_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_35 (Activation)             (None, 14, 14, 256)        0             bn4e_branch2a[0][0]
________________________________________________________________________________________________________________________
res4e_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_35[0][0]
________________________________________________________________________________________________________________________
bn4e_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4e_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_36 (Activation)             (None, 14, 14, 256)        0             bn4e_branch2b[0][0]
________________________________________________________________________________________________________________________
res4e_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_36[0][0]
________________________________________________________________________________________________________________________
bn4e_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4e_branch2c[0][0]
________________________________________________________________________________________________________________________
add_12 (Add)                           (None, 14, 14, 1024)       0             bn4e_branch2c[0][0]
                                                                                activation_34[0][0]
________________________________________________________________________________________________________________________
activation_37 (Activation)             (None, 14, 14, 1024)       0             add_12[0][0]
________________________________________________________________________________________________________________________
res4f_branch2a (Conv2D)                (None, 14, 14, 256)        262400        activation_37[0][0]
________________________________________________________________________________________________________________________
bn4f_branch2a (BatchNormalization)     (None, 14, 14, 256)        1024          res4f_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_38 (Activation)             (None, 14, 14, 256)        0             bn4f_branch2a[0][0]
________________________________________________________________________________________________________________________
res4f_branch2b (Conv2D)                (None, 14, 14, 256)        590080        activation_38[0][0]
________________________________________________________________________________________________________________________
bn4f_branch2b (BatchNormalization)     (None, 14, 14, 256)        1024          res4f_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_39 (Activation)             (None, 14, 14, 256)        0             bn4f_branch2b[0][0]
________________________________________________________________________________________________________________________
res4f_branch2c (Conv2D)                (None, 14, 14, 1024)       263168        activation_39[0][0]
________________________________________________________________________________________________________________________
bn4f_branch2c (BatchNormalization)     (None, 14, 14, 1024)       4096          res4f_branch2c[0][0]
________________________________________________________________________________________________________________________
add_13 (Add)                           (None, 14, 14, 1024)       0             bn4f_branch2c[0][0]
                                                                                activation_37[0][0]
________________________________________________________________________________________________________________________
activation_40 (Activation)             (None, 14, 14, 1024)       0             add_13[0][0]
________________________________________________________________________________________________________________________
res5a_branch2a (Conv2D)                (None, 7, 7, 512)          524800        activation_40[0][0]
________________________________________________________________________________________________________________________
bn5a_branch2a (BatchNormalization)     (None, 7, 7, 512)          2048          res5a_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_41 (Activation)             (None, 7, 7, 512)          0             bn5a_branch2a[0][0]
________________________________________________________________________________________________________________________
res5a_branch2b (Conv2D)                (None, 7, 7, 512)          2359808       activation_41[0][0]
________________________________________________________________________________________________________________________
bn5a_branch2b (BatchNormalization)     (None, 7, 7, 512)          2048          res5a_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_42 (Activation)             (None, 7, 7, 512)          0             bn5a_branch2b[0][0]
________________________________________________________________________________________________________________________
res5a_branch2c (Conv2D)                (None, 7, 7, 2048)         1050624       activation_42[0][0]
________________________________________________________________________________________________________________________
res5a_branch1 (Conv2D)                 (None, 7, 7, 2048)         2099200       activation_40[0][0]
________________________________________________________________________________________________________________________
bn5a_branch2c (BatchNormalization)     (None, 7, 7, 2048)         8192          res5a_branch2c[0][0]
________________________________________________________________________________________________________________________
bn5a_branch1 (BatchNormalization)      (None, 7, 7, 2048)         8192          res5a_branch1[0][0]
________________________________________________________________________________________________________________________
add_14 (Add)                           (None, 7, 7, 2048)         0             bn5a_branch2c[0][0]
                                                                                bn5a_branch1[0][0]
________________________________________________________________________________________________________________________
activation_43 (Activation)             (None, 7, 7, 2048)         0             add_14[0][0]
________________________________________________________________________________________________________________________
res5b_branch2a (Conv2D)                (None, 7, 7, 512)          1049088       activation_43[0][0]
________________________________________________________________________________________________________________________
bn5b_branch2a (BatchNormalization)     (None, 7, 7, 512)          2048          res5b_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_44 (Activation)             (None, 7, 7, 512)          0             bn5b_branch2a[0][0]
________________________________________________________________________________________________________________________
res5b_branch2b (Conv2D)                (None, 7, 7, 512)          2359808       activation_44[0][0]
________________________________________________________________________________________________________________________
bn5b_branch2b (BatchNormalization)     (None, 7, 7, 512)          2048          res5b_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_45 (Activation)             (None, 7, 7, 512)          0             bn5b_branch2b[0][0]
________________________________________________________________________________________________________________________
res5b_branch2c (Conv2D)                (None, 7, 7, 2048)         1050624       activation_45[0][0]
________________________________________________________________________________________________________________________
bn5b_branch2c (BatchNormalization)     (None, 7, 7, 2048)         8192          res5b_branch2c[0][0]
________________________________________________________________________________________________________________________
add_15 (Add)                           (None, 7, 7, 2048)         0             bn5b_branch2c[0][0]
                                                                                activation_43[0][0]
________________________________________________________________________________________________________________________
activation_46 (Activation)             (None, 7, 7, 2048)         0             add_15[0][0]
________________________________________________________________________________________________________________________
res5c_branch2a (Conv2D)                (None, 7, 7, 512)          1049088       activation_46[0][0]
________________________________________________________________________________________________________________________
bn5c_branch2a (BatchNormalization)     (None, 7, 7, 512)          2048          res5c_branch2a[0][0]
________________________________________________________________________________________________________________________
activation_47 (Activation)             (None, 7, 7, 512)          0             bn5c_branch2a[0][0]
________________________________________________________________________________________________________________________
res5c_branch2b (Conv2D)                (None, 7, 7, 512)          2359808       activation_47[0][0]
________________________________________________________________________________________________________________________
bn5c_branch2b (BatchNormalization)     (None, 7, 7, 512)          2048          res5c_branch2b[0][0]
________________________________________________________________________________________________________________________
activation_48 (Activation)             (None, 7, 7, 512)          0             bn5c_branch2b[0][0]
________________________________________________________________________________________________________________________
res5c_branch2c (Conv2D)                (None, 7, 7, 2048)         1050624       activation_48[0][0]
________________________________________________________________________________________________________________________
bn5c_branch2c (BatchNormalization)     (None, 7, 7, 2048)         8192          res5c_branch2c[0][0]
________________________________________________________________________________________________________________________
add_16 (Add)                           (None, 7, 7, 2048)         0             bn5c_branch2c[0][0]
                                                                                activation_46[0][0]
________________________________________________________________________________________________________________________
activation_49 (Activation)             (None, 7, 7, 2048)         0             add_16[0][0]
________________________________________________________________________________________________________________________
avg_pool (GlobalAveragePooling2D)      (None, 2048)               0             activation_49[0][0]
________________________________________________________________________________________________________________________
up_sampling2d_1 (UpSampling2D)         (None, 224, 224, 2048)     0             activation_49[0][0]
________________________________________________________________________________________________________________________
fc1000 (Dense)                         (None, 1000)               2049000       avg_pool[0][0]
________________________________________________________________________________________________________________________
predictions_2 (Conv2D)                 (None, 224, 224, 1000)     2049000       up_sampling2d_1[0][0]
========================================================================================================================
Total params: 27,685,712
Trainable params: 27,632,592
Non-trainable params: 53,120
________________________________________________________________________________________________________________________

——————————————————————

总目录

keras的example文件解析

你可能感兴趣的:(TensorFlow,python)