Caffe中用訓練好的模型測試,deploy檔案的修改方法
阿新 • • 發佈:2019-02-13
訓練好網路模型後,需要在測試集上驗證模型分類的正確率,這時,就需要把訓練的網路檔案net.prototxt
修改為deploy.prototxt
,然後再進行測試。
輸入資料層改動如下:
name: "SpecNet"
layer {
name: "spectr"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
scale: 0.00390625
}
data_param {
source: "../data/train"
batch_size: 15
backend: LMDB
}
}
layer {
name: "spectr"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
scale: 0.00390625
}
data_param {
source: "../data/valid"
batch_size: 15
backend: LMDB
}
}
# Layer 1 128x128x1
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
}
param {
lr_mult: 1
}
...
...
...
改為:
name: "SpecNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 1 dim: 3 dim: 128 dim: 128 } }
}
# Layer 1 128x128x1
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
}
param {
lr_mult: 1
}
...
...
...
其中
dim: 1 #num,對待識別樣本進行資料增廣的數量,可自行定義。一般會進行5次crop,之後分別flip。如果該值為10則表示一個樣本會變成10個,之後輸入到網路進行識別。如果不進行資料增廣,可以設定成1
dim: 3 #通道數,表示RGB三個通道
dim: 128 #影象的長和寬
input_param的引數解釋:http://blog.csdn.net/u010417185/article/details/52619593
輸出層改動如下:
# Classification Layer 6x1
layer {
name: "accuracy"
type: "Accuracy"
bottom: "ip2"
bottom: "label"
top: "accuracy"
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "ip2"
bottom: "label"
top: "loss"
}
...
...
...
改為:
# Classification Layer 6x1
#layer {
# name: "accuracy"
# type: "Accuracy"
# bottom: "ip2"
# bottom: "label"
# top: "accuracy"
#}
layer {
name: "prob"
type: "Softmax"
bottom: "ip2"
# bottom: "label"
top: "prob"
}
...
...
...