訓練好網絡模型後,需要在測試集上驗證模型分類的正確率,這時,就需要把訓練的網絡文件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"
}
...
...
...
只需要改輸入數據層和輸出層,其他的一般不用修改。
可以參考:
http://blog.csdn.net/l18930738887/article/details/54898016
http://blog.csdn.net/lanxuecc/article/details/52474476
http://blog.csdn.net/fx409494616/article/details/53008971