本文是在拜讀了該博主的文章:【卷積神經網絡提取特徵並用於SVM】之後,個人對代碼內容邏輯的思考
注:請先看下博主的源代碼,本文只是簡單畫了一下整個邏輯圖,方便自己去理解。
如下圖:(主要內容在 ①②③,前面的內容請自行忽略。)
自己嘗試並驗證結果:
圖上的參數說明:
圖上的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。。。讓我在考慮考慮