How to compute test/validation loss in pycaffe

I am trying to compute the test loss in my own training loop in python. Calling solver.test_nets[0].forward() seems to update the score blob but not the loss one. Any idea how to get it updated?

I am using the following solver config:

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

and train and test.prototxt are exactly the same except for the phase definition at the top of the file:

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

Answers


It was actually a different issue that what I thought. The loss blob was being updated but it remained the same because the weights of solver.test_nets[0] were not changing. It looks like they not automatically shared with solver.net. This can be done by simply calling:

solver.test_nets[0].share_with(solver.net)

Need Your Help

Running jacocoReport

java scala gradle jacoco

I'm using gradle 1.7 and jacoco plugin.