caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Calculate accuracy on both train and test?

Open biagio90 opened this issue 12 years ago • 3 comments

Hi everybody, I am working on plotting statistics like the accuracy over iterations. I use parse_log and gnuplot for that. Now my problem is that I need accuracy for both testset and trainset. In other words, I want that the TEST phase will be applied on both databases and as a result give me two accuracy numbers in order to see how the two courves evolve. It should also have different test iteration, since the training set is usually bigger than the test set.

Is it possible somehow? Thanks

biagio90 avatar Oct 22 '14 12:10 biagio90

I encountered that problem yesterday and here is how I resolve it: At the end of .prototxt file I add: layers { name: "accuracy_train" type: ACCURACY bottom: "fc8_flickr" bottom: "label" top: "accuracy_train" include: { phase: TRAIN } } This will print accuracy value from train data, in TRAIN phase.

And about frequency of testing data: I am not sure about it, but I change parameter "Display" at solver, I think that there is other option, but I do not know which.

melgor avatar Oct 24 '14 05:10 melgor

Apply accuracy to train phase was my first idea too, but it is not a good solution. It calculates the accuracy only on the small batch, but I want the accuracy on the whole training set each X iteration, as it happens for the test phase. I have a batch size of 20 images because of GPU-memory issue, so in my case it is not a good approach.

biagio90 avatar Oct 24 '14 06:10 biagio90

Refer to the MNIST autoencoder solver: https://github.com/BVLC/caffe/blob/master/examples/mnist/mnist_autoencoder_solver.prototxt

It defines two tests nets, one for the training set and one for the test set, which are both included in the same model definition prototxt by the STAGE filter rules. It likewise defines the number of test iterations for the train and test sets separately, since they need not be the same size.

On Thursday, October 23, 2014, Biagio [email protected] wrote:

Apply accuracy to train phase was my first idea too, but it is not a good solution. It calculates the accuracy only on the small batch, but I want the accuracy on the whole training set each X iteration, as it happens for the test phase. I have a batch size of 20 images because of GPU-memory issue, so in my case it is not a good approach.

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/1345#issuecomment-60350349.

Evan Shelhamer

shelhamer avatar Oct 24 '14 15:10 shelhamer