關於某博主的卷積神經網絡提取特徵並用於SVM文章的個人思路分析

本文是在拜讀了該博主的文章:【卷積神經網絡提取特徵並用於SVM】之後,個人對代碼內容邏輯的思考

注:請先看下博主的源代碼,本文只是簡單畫了一下整個邏輯圖,方便自己去理解。

如下圖:(主要內容在 ①②③,前面的內容請自行忽略。)
resultsss
自己嘗試並驗證結果:

圖上的參數說明:
圖上的x_image在代碼裏我設置名稱爲features
x_image_features在代碼中是features_prase

代碼裏的參數說明:
E_poch:一共打算訓練多少遍
train_batch_idxs:訓練一遍要多少個batch(每個batch含50個img)

# region一、訓練
for i in range(E_poch):
	for j in range(train_batch_idxs):
	    value, label = sess.run([x_train_batch, y_train_batch])
	    label_onehot = dense_to_one_hot(label, 7)
	    # 驗證結果
	    features_prase = sess.run(features, feed_dict={x: value,
	                                                   y_true: label_onehot,
	                                                   keep_prob: 1.0})
	    print("features=", type(features))
	    print("features_prase=", type(features_prase))
	    for i in range(50):
	        print("features_prase:\n", len(features_prase[i]))
         	print("features_prase:\n", features_prase[i])
            print("怎麼查看shape呀?我是憨批。")
	
	    exit(0)
# endregion

運行結果:
運行結果
這樣我們應該就算是完成了圖上的②。應該就可以進行接下來的③了。

tip:以前沒用過SVM。但是根據作者代碼的意思,SVM是一次加入全部的訓練數據。所以。。。我的批次要一下子拿完全部數據。。。emmm。。。讓我在考慮考慮

附1:圖像數據不夠?來數據擴增吧
附2:什麼?分類精度不夠高。試試K折交叉驗證吧。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章