1

我想知道如何在 Caffe 中仅为 LMDB 文件设置一个测试阶段。我已经训练了我的模型,一切看起来都很好,我的损失减少了,我在一张一张加载的图像上得到的输出也看起来不错。

现在我想看看我的模型在单独的 LMDB 测试集上的表现如何,但似乎无法成功。一次加载一张图片对我来说并不理想,因为我的损失函数已经在 caffe 中定义了,这需要我重新定义它。

这是我到目前为止所拥有的,但是这样做的结果没有意义;当我将火车组的损失与我从中获得的损失进行比较时,它们不匹配(相差几个数量级)。有谁知道我的问题可能是什么?

caffe.set_device(0)
caffe.set_mode_gpu()

net = caffe.Net('/home/jeremy/Desktop/caffestuff/JP_Kitti/all_proto/mirror_shuffle/deploy_JP.prototxt','/home/jeremy/Desktop/caffestuff/JP_Kitti/all_proto/mirror_shuffle/snapshot_iter_10000.caffemodel',caffe.TEST)


solver = None  # ignore this workaround for lmdb data (can't instantiate two solvers on the same data)
solver = caffe.SGDSolver('/home/jeremy/Desktop/caffestuff/JP_Kitti/all_proto/mirror_shuffle/lenet_auto_solverJP_test.prototxt')
niter = 100
test_loss = zeros(niter)
count = 0
for it in range(niter):
    solver.test_nets[0].forward()  # SGD by Caffe

    # store the test loss

    test_loss[count] = solver.test_nets[0].blobs['loss']
    print(solver.test_nets[0].blobs['loss'].data)
    count = count+1
4

1 回答 1

0

在这里查看我的答案。不要忘记减去平均值,否则你会得到低准确率。上面发布的代码链接可以解决这个问题。

于 2016-06-28T06:18:03.150 回答