0
私はカフェのC++ classification例を使用しようとしている

(私はMNISTデータベース上の私のモデルを訓練)手書き数字で画像を分類する(ここではcodeである)を返しますが、それはいつものように確率を返します。カフェのclassifocation.cppは常に100%の確率

[0, 0, 0, 1.000, 0, 0, 0, 0, 0] (1.000 can be on different position) 

画像に数字がなくても。私はそれが

[0.01, 0.043, ... 0.9834, ... ] 

のようなものも、「9」のために例えば、それは常に間違った番号を予測していますすべきだと思います。私はclassification.cppに変更
一つだけの事は、私は常にCPU

//#ifdef CPU_ONLY  
    Caffe::set_mode(Caffe::CPU); // <----- always CPU 
//#else 
// Caffe::set_mode(Caffe::GPU); 
//#endif 

を使用しています。これは、

name: "LeNet" 
layer { 
    name: "data" 
    type: "ImageData" 
    top: "data" 
    top: "label" 
    image_data_param { 
    source: "D:\\caffe-windows\\examples\\mnist\\test\\file_list.txt" 
    } 
} 
layer { 
    name: "conv1" 
    type: "Convolution" 
    bottom: "data" 
    top: "conv1" 
    param { 
    lr_mult: 1 
    } 
    param { 
    lr_mult: 2 
    } 
    convolution_param { 
    num_output: 20 
    kernel_size: 5 
    stride: 1 
    weight_filler { 
     type: "xavier" 
    } 
    bias_filler { 
     type: "constant" 
    } 
    } 
} 
layer { 
    name: "pool1" 
    type: "Pooling" 
    bottom: "conv1" 
    top: "pool1" 
    pooling_param { 
    pool: MAX 
    kernel_size: 2 
    stride: 2 
    } 
} 
layer { 
    name: "conv2" 
    type: "Convolution" 
    bottom: "pool1" 
    top: "conv2" 
    param { 
    lr_mult: 1 
    } 
    param { 
    lr_mult: 2 
    } 
    convolution_param { 
    num_output: 50 
    kernel_size: 5 
    stride: 1 
    weight_filler { 
     type: "xavier" 
    } 
    bias_filler { 
     type: "constant" 
    } 
    } 
} 
layer { 
    name: "pool2" 
    type: "Pooling" 
    bottom: "conv2" 
    top: "pool2" 
    pooling_param { 
    pool: MAX 
    kernel_size: 2 
    stride: 2 
    } 
} 
layer { 
    name: "ip1" 
    type: "InnerProduct" 
    bottom: "pool2" 
    top: "ip1" 
    param { 
    lr_mult: 1 
    } 
    param { 
    lr_mult: 2 
    } 
    inner_product_param { 
    num_output: 500 
    weight_filler { 
     type: "xavier" 
    } 
    bias_filler { 
     type: "constant" 
    } 
    } 
} 
layer { 
    name: "relu1" 
    type: "ReLU" 
    bottom: "ip1" 
    top: "ip1" 
} 
layer { 
    name: "ip2" 
    type: "InnerProduct" 
    bottom: "ip1" 
    top: "ip2" 
    param { 
    lr_mult: 1 
    } 
    param { 
    lr_mult: 2 
    } 
    inner_product_param { 
    num_output: 10 
    weight_filler { 
     type: "xavier" 
    } 
    bias_filler { 
     type: "constant" 
    } 
    } 
} 
layer { 
    name: "loss" 
    type: "Softmax" 
    bottom: "ip2" 
    top: "loss" 
}  

file_list.txtが

であるように私のdeploy.prototxtがどのように見えるかということです
D:\caffe-windows\examples\mnist\test\test1.jpg 0 

tests1.jpgは次のようなものです

enter image description here

(黒&白28 * 28の画像ペイントで保存された)、私は、異なるサイズを試してみましたが、それは(、Preprocces問題ではないとにかくそれをリサイズ)

ここで、私はthisチュートリアルを使用するネットワークを訓練するために、 prototxt

なぜ、間違った数字が予測され、常に100%の確率で予測されますか?

あなたの "ImageDataを" 層で

答えて

1

(Iは、Windows 7、VS13を使用しています)は、[0、1] "規模" にすることによりに[0、255]からあなたtest1.jpgデータを正規化する必要があります次のようなトレーニングとテストの間で前処理の一貫性を保ちます。

image_data_param { 
    source: "D:\\caffe-windows\\examples\\mnist\\test\\file_list.txt" 
    scale: 0.00390625 
    } 
+0

ありがとう、それは問題を解決しました –