第一步,构造网络:
enum Phase p = TEST;
Net
caffe_test_net.CopyTrainedLayersFrom(argv[2]);
第二步,构造数据并加入到网络输入层:
//create the input data
vector
vector
//////operations for the input data
Mat original = imread("images\\lena_gray.png"); //随便的图片,没有实用意义,可忽略
Mat *sub_img = new Mat;
for (int i = 0; i < 10; i++){
original(Range(i, i + 28), Range(i, i + 28)).copyTo(*sub_img); // 28x28,可以直接用lenet
md_images.push_back(*sub_img);
md_labels.push_back(0);
}
第三步,执行test操作:
for (int i = 0; i < 10; i++){
const vector