在咖啡館我只是在使用ImageNet數據集訓練的alexnet架構的前訓練權重,僅用於前兩層,我想在這兩層之後添加一個softmax分類器。我想知道如何才能從包含更大網絡結構(真正的「深」Alexnet結構)的權重文件中提取僅前兩層的權重。您可以從網絡的前3層複製權重嗎?不完全微調,但幾乎重塑
1
A
回答
1
爲了增加Shai的答案 -
如果你不想全部權重文件,
爲了提取所需層的權重,使用net surgery:
net = caffe.Net(prototxt, caffemodel, caffe.TRAIN)
outnet = caffe.Net(predefined_prototxt_with_desired_layers_only, caffe.TRAIN)
layers_to_copy = ['conv1', 'conv2', 'conv3']
for layer in layers_to_copy:
for i in range(0, len(net.params[layer])): #this is for copying both weights and bias, in case bias exists
outnet.params[layer][i].data[...]=np.copy(net.params[layer][i].data[...])
outnet.save(new_caffemodel_name)
0
Caffe使用圖層的"name"
爲圖層的blobs
分配權重。 如果您更改頂層'"name"
',則caffe將不會複製原始.caffemodel
文件中的權重。
相關問題
- 1. 重定向到https幾乎工作,但不完全
- 2. 重塑矩陣以獲得網絡
- 3. 多層神經網絡中的權重
- 4. 重塑張量流代碼中完全連通層的輸入?
- 5. 移除幾乎重複行
- 6. CAFFE重塑/上採樣完全連接層
- 7. 網站在IE瀏覽器中幾乎完全不可禁用
- 8. 我可以阻止AngularJS完全重建DOM的重複部分嗎?
- 9. parse_edgelist重複加權網絡? python networkx
- 10. Lightswitch + WCF RIA + MySQL連接器/ Net幾乎可以工作但不完全
- 11. 列表框與IValueConverter Bool是是否...幾乎可以工作,但不完全
- 12. 輸入維度Tensorflow conolutional網絡重塑
- 13. Javascript幾乎可以工作,但它會重新加載頁面?
- 14. 下拉菜單幾乎可以工作,但並不完美
- 15. 網站可以完全安全嗎?
- 16. PyBrain ANN的權重幾乎沒有變化,但工作
- 17. 您可以重複使用更新值以進行重複密鑰更新嗎?
- 18. 可以重複調用BZ2_bzBuffToBuffCompress()嗎?
- 19. 我的多層神經網絡收斂太慢(幾乎不可用)
- 20. 幾乎JSON的正則表達式但不完全
- 21. 您可以重載.hpp文件中的全局運算符嗎?
- 22. 宏重複幾乎相同的代碼
- 23. 選擇(幾乎)重複的行
- 24. OpenCV神經網絡權重
- 25. 添加邊緣權重以繪製網絡中的輸出x
- 26. 快速排序:幾乎排序,但不完全。怎麼了?
- 27. Unity:等待()在更新幾乎工作(但不完全)
- 28. viewDidLoad可以在viewController的'init'完全執行之前調用嗎?
- 29. 深層神經網絡權重的評估
- 30. 您可以重複使用$ scope $ watch