I've faced some problems with testing trained machine.
I've trained lenet5 machine for MINST dataset following MNIST demo tutorial. When I load it from file and testing it with supervised_trainer it works fine.
But when I try to use it on some test image I have zero outputs for all my classes.
Here is my code for recognition of single test image:
////////////////////////////////////////////////////////////////////////////////
string class_l5_path("mnist_trained_network.mat");
parameter<fs(double)> theparam;
theparam.resize(1);
theparam.load_x(class_l5_path.c_str());
lenet5<fs(double)> l5(theparam, 32, 32, 5, 5, 2, 2, 5, 5, 2, 2, 120, 10);
// I don't have ImageMagick, so I load image using OpenCV end resize it to 32x32
Mat image_orig = imread("test_image.png");
vector<Mat> image_channels;
split(image_orig, image_channels);
Mat image;
resize(image_channels[0], image, Size(32, 32));
idx<ubyte> image_idx(32, 32);
// Copying OpenCV image in idx
for (int i = 0; i < image.rows; ++i)
for (int j = 0; j < image.cols; ++j)
image_idx.set(image.at<unsigned char>(i, j), i, j);
fstate_idx<double> stin(1, image.rows, image.cols);
idx<double> inx = stin.x.select(0, 0);
idx_copy(image_idx, inx);
fstate_idx<double> stout(1,1,1);
l5.fprop(stin, stout);
for (int i = 0; i < stout.x.dim(0); ++i)
cout << stout.x.get(i) << " ";
/////////////////////////////////////////////////////////////////////////////
So the problem is that all outputs are equal to zero (output of cout is "0 0 0 0 0 0 0 0 0 0"). Could you help and tell me what I'm doing wrong or show me where I can find a code example with using trained network on test image?
Regards,
Sergey Milyaev
--