http://caffe.berkeleyvision.org/gathered/examples/mnist.htmlに従って、mnist データベースで Caffe ネットのトレーニングに成功しました。
ここで、Matlab ラッパーを使用して独自の画像でネットワークをテストしたいと考えています。
したがって、「matcaffe.m」では、トレーニングには使用されませんが、テストには適していると思われるファイル「lenet.prototxt」をロードします。28 x 28 ピクセルの入力サイズを参照しています。
name: "LeNet"
input: "data"
input_dim: 64
input_dim: 1
input_dim: 28
input_dim: 28
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
したがって、それに応じて「matcaffe.m」の「prepare_image」関数を調整しました。次のようになります。
% ------------------------------------------------------------------------
function images = prepare_image(im)
IMAGE_DIM = 28;
% resize to fixed input size
im = rgb2gray(im);
im = imresize(im, [IMAGE_DIM IMAGE_DIM], 'bilinear');
im = single(im);
images = zeros(1,1,IMAGE_DIM,IMAGE_DIM);
images(1,1,:,:) = im;
images = single(images);
%-------------------------------------------------------------
これは、入力画像を [1 x 1 x 28 x 28]、4dim、グレースケール画像に変換します。しかし、それでもMatlabは不平を言っています:
Error using caffe
MatCaffe input size does not match the input size of the
network
Error in matcaffe_myModel_mnist (line 76)
scores = caffe('forward', input_data);
トレーニング済みの mnist ネットを自分のデータでテストした経験がある人はいますか?