【发布时间】:2018-03-29 14:07:37
【问题描述】:
我在训练阶段和测试阶段都有一个准确度层。
我还尝试从PyCaffe 训练Caffe,以便更好地绘制曲线。
但是我注意到,使用
solver.test_nets[0].blobs['accuracy'].data
与我自己计算的不同:
def run_test(solver, test_iter):
'''
Tests the network on all test set and calculates the test accuracy
'''
correct = 0
batch_size_test = solver.test_nets[0].blobs['data'].data.shape[0]
for test_it in range(test_iter):
#testing the network on all test set and calculate the test accuracy
solver.test_nets[0].forward()
correct += sum(solver.test_nets[0].blobs['ip1'].data.argmax(1) == solver.test_nets[0].blobs['label'].data)
acc = correct / (test_iter * batch_size_test)
return acc
run_test 返回的准确度与 Caffe 在控制台屏幕上报告的准确度相同。
这里有什么问题?
我的训练阶段准确率和损失也有这个问题,再次表示
train_loss[it] = solver.net.blobs['loss'].data
training_acc = str(solver.net.blobs['accuracy_training'].data)
与 Caffe 在控制台屏幕中报告的值不同。
【问题讨论】: