I'm having trouble finding a
C++ example that directly uses Caffe's
net interface to make a prediction for a net input with more than the usual three channels. Currently, I'm using the code
beniz posted in
https://github.com/BVLC/caffe/issues/1443. My
C++ code looks like this:
caffe::Net<float> net(model_file, caffe::TEST);
net.CopyTrainedLayersFrom(weights_file);
float loss = 0.0;
std::vector<cv::Mat> dv; // = images; // image is a cv::Mat, as I'm using #1416
cv::Mat img;
images[1].convertTo(img, CV_8U);
dv.push_back(img);
std::vector<int> dvl;
dvl.push_back(0);
boost::dynamic_pointer_cast< caffe::MemoryDataLayer<float> >(net.layers()[0])->AddMatVector(dv,dvl);
std::vector<Blob<float>*> results = net.Forward(&loss);
I also have the following
Matlab code:
net = caffe.Net(deployFile, weightsFile, 'test');
dataShape = net.blobs('data').shape;
image = images{1};
inputImage = zeros(dataShape);
inputImage(:,:,:,1) = image;
probs = net.forward({inputImage});
I'm wondering why the values contained in the variable
results are very different from the ones contained in
probs for the same image. For example: probs = (107.5973, -110.9885), results = (1.30978,
1: -1.3908). Is this typical?