【发布时间】:2016-10-30 02:38:12
【问题描述】:
我想知道如何在 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
【问题讨论】: