如何计算pycaffe中的测试/验证损失

时间:2016-07-21 18:13:06

标签: deep-learning caffe pycaffe

我正在尝试在python中训练我自己的训练循环中的测试损失。调用solver.test_nets[0].forward()似乎更新score blob而不是loss blob。知道如何更新吗?

我正在使用以下解算器配置:

net: "/tmp/tmp8ikb9sg2/train.prototxt"
test_net: "/tmp/tmp8ikb9sg2/test.prototxt"
test_iter: 1
test_interval: 2147483647
base_lr: 0.1
lr_policy: "fixed"
test_initialization: false

和train和test.prototxt完全相同,除了文件顶部的阶段定义:

name: "pycaffenet"
state {
  phase: TRAIN  # set TEST in test.prototxt
}
...
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "score"
  bottom: "output"
  top: "loss"
}

1 个答案:

答案 0 :(得分:1)

这实际上是我想到的另一个问题。 loss blob正在更新,但它保持不变,因为solver.test_nets[0]的权重没有变化。看起来它们不会自动与solver.net共享。这可以通过简单地调用:

来完成
solver.test_nets[0].share_with(solver.net)