mnist with custom handwritting data , low accuracy

41 views
Skip to first unread message

jun wei Chen

unread,
Dec 31, 2015, 10:21:22 AM12/31/15
to Caffe Users
hi , guys 
i run on custom data, but the accuracy is very low , even after 10000 iterations
when i input " 7 " ,  output " 3 "  most of the time 
my data is white background and black digits

this is my code :

import numpy as np
import cv2
import caffe

caffe_root
= "./"

caffe
.set_mode_gpu()

net
= caffe.Net(caffe_root + 'examples/mnist/lenet.prototxt',
               caffe_root
+ "examples/mnist/lenet_iter_10000.caffemodel",
               caffe
.TEST)


transformer
= caffe.io.Transformer({'data':net.blobs['data'].data.shape})
transformer
.set_transpose('data',(2,0,1))

net
.blobs['data'].reshape(1,1,28,28)

images
= cv2.imread(caffe_root + "examples/mnist/lenet/image/7_5.jpg",cv2.CV_8UC1)
images
= np.reshape(images,(images.shape[0],images.shape[1],1))

#white background
images
= 255 - images

net
.blobs['data'].data[...] = transformer.preprocess('data',images)
out = net.forward()
print("Predicted class is #{}.".format(out['prob'].argmax()))



Reply all
Reply to author
Forward
0 new messages