Perform the validation loss from .caffemodel?

Viewed 363

AFAIK, we have two ways to obtain the validation loss.
(1) online during training process by setting the solver as follows: train_net: 'train.prototxt'

test_net: "test.prototxt"
test_iter: 200
test_interval: 100

(2) offline based on the weight in the .caffemodel file. In this question, I regard to the second way due to limited GPU. First, I saved the weight of network to .caffemodel after each 100 iterations by snapshot: 100. Based on these .caffemodel, I want to calculate the validation loss

../build/tools/caffe test -model ./test.prototxt -weights $snapshot -iterations 10 -gpu 0 

where snapshot is file name of .caffemodel. For example snap_network_100.caffemodel

And the data layer of my test prototxt is

layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  hdf5_data_param {
    source: "./list.txt"
    batch_size: 8
    shuffle: true
  }
}

The first and the second ways give different validation loss. I found that the first way the validation loss independent of batch size. It means the validation loss is same with different batch size. While, the second way, the validation loss changed with different batch size but the loss is very close together with different iterations.

My question is that which way is correct to compute validation loss?

1 Answers
Related