iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 21
0
AI & Data

AI+Line系列 第 21

Day21 CNN卷積神經網路程式(9):卷積層filter所認的特徵

顯示剛剛的數字7圖片看看

test_image = np.reshape(x_test[0], [1, 1, 28, 28])
plt.imshow(np.reshape(test_image, [28, 28]), cmap='gray')
plt.title('Test Image')
plt.axis('off')
plt.show()

然後用以下的程式,選出一個layer,把這層的filter所看到的圖,顯示出來

layer_model = Model(inputs=model.input, outputs=model.get_layer('conv2d_1').output)
conv1_ = layer_model.predict(test_image)
print(conv1_.shape)

conv1_img_ = conv1_[0,:,:,:]
fig, axes = plt.subplots(4, 8, figsize=(15, 8))
fig.subplots_adjust(hspace=0.5, wspace=0.5)

for i, ax in enumerate(axes.flat):
    ax.imshow(conv1_img_[i,:,:], cmap='gray')
    xlabel = "Filter : {}".format(i+1)
    ax.set_xlabel(xlabel)
    ax.set_xticks([])
    ax.set_yticks([])      
fig.suptitle('Output of the first convolutional layer')  
plt.show()

會發現這層的32個過濾器,有的特別看直線、有的看斜線、有的看轉角...,看來CNN機器學習所看到的世界,跟人看到的很不一樣,但仍然是宇宙中其中一種認識世界的方法
https://imgur.com/ywFbuFZ.png


上一篇
Day20 CNN卷積神經網路程式(8):評估辨識能力
下一篇
Day22 大數據(1):流程
系列文
AI+Line30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言