Caffe : cifar 10_quick testing issue
Question: I have trained CIFAR QUICK using caffe, but when I test the
cifar10_quick_iter_5000.caffemodel.h5 using a python wrapper I get an accuracy
around 52-54% whereas it should be 75%. I do not understand why I am geting
such a low accuracy, because when I test Lenet MNIST I get the expected
accuracy as per the MNIST example in caffe website. To verify if my method is
right or wrong I have tried the cifar trained model file from
[Clasificador_Cifar-10](https://github.com/IsaacRocos/Clasificador_Cifar-10.git)
and I get and accuracy of 68%.

Please let me know if I am missing something when I test the model.

    
    
    import sys
    import caffe
    import cv2
    import Image
    import matplotlib
    import numpy as np
    import lmdb
    caffe_root = '/home/fred/CIFAR_QUICK/caffe'
    
    MODEL_FILE = '/home/fred/CIFAR_QUICK/caffe/examples/cifar10/cifar10.prototxt'
    PRETRAINED = '/home/fred/CIFAR_QUICK/caffe/examples/cifar10/cifar10_60000.caffemodel.h5'
    
    net = caffe.Net(MODEL_FILE, PRETRAINED,caffe.TEST)
    caffe.set_mode_cpu()
    db_path = '/home/fred/CIFAR_QUICK/caffe/examples/cifar10/cifar10_test_lmdb'
    lmdb_env = lmdb.open(db_path)
    lmdb_txn = lmdb_env.begin()
    lmdb_cursor = lmdb_txn.cursor()
    count = 0
    correct = 0
    for key, value in lmdb_cursor:
        print "Count:"
        print count
        count = count + 1
        datum = caffe.proto.caffe_pb2.Datum()
        datum.ParseFromString(value)
        label = int(datum.label)
        image = caffe.io.datum_to_array(datum)
        image = image.astype(np.uint8)
        out = net.forward_all(data=np.asarray([image]))
        predicted_label = out['prob'][0].argmax(axis=0)
        print out['prob']
        if label == predicted_label:
            correct = correct + 1
        print("Label is class " + str(label) + ", predicted class is " + str(predicted_label))
    
    print(str(correct) + " out of " + str(count) + " were classified correctly")
    


Answer: See my answer [here](http://stackoverflow.com/a/35572495/3579977). You are not
subtracting the mean which results in low accuracy. The link to the code,
posted above, takes care of that. Apart from this there's nothing wrong with
your approach.

