BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.07k stars 18.7k forks source link

What is wrong with the training getting same output? #2300

Closed iec2011007 closed 9 years ago

iec2011007 commented 9 years ago

I have fine tuned my model caffenet model for just 1000 iteration(was just checking the parameter) the reported accuracy during training was 0.24(24% am i right ?) but during the testing phase i get the following result in which all the class probability are same even the numbers dont change.

screenshot from 2015-04-11 14 37 18

the code which i have used for testing is

import numpy as np import sys sys.path.append('/home/cbir/caffe/caffe/python') import caffe import matplotlib.pyplot as plt import os

caffe_root = '/home/cbir/caffe/caffe/'

MODEL_FILE = '/home/cbir/caffe/caffe/models/model40000/deploy.prototxt' PRETRAINED = '/home/cbir/caffe/caffe/models/model40000/finetune_gagnam_style_iter_1000.caffemodel'

IMAGE_FILE = '/home/cbir/dataset/images2000/Soch-Red-Printed-Cotton-Kurti-SDL698146756-3-ac0f2.jpg'

IMAGE_FILE = '/home/cbir/dataset/sweater/SDL447052269_1366788957_image2-a9389.jpg'

IMAGE_FILE = '/images/test/images/' caffe.set_mode_cpu() net = caffe.Classifier(MODEL_FILE, PRETRAINED, mean=np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1).mean(1), image_dims=(256, 256))

filenames = next(os.walk(IMAGE_FILE))[2] for name in filenames : print IMAGE_FILE + name input_image = caffe.io.load_image(IMAGE_FILE + name)

plt.imshow(input_image)

prediction = net.predict([input_image])
print 'predicted class:', prediction[0].argmax(), prediction[0]

What is wrong Please Help? PS : I have randomized the input image.

I just have 4 classes so there were only minor variation in the train.val.prototxt I just changed the datasource and the num of outputs and used the train_val.prototxt from the finetune_flickr_style

Xiaomi2008 commented 9 years ago

I'm having the same problem, whatever image input produce just the same outputs

lugiavn commented 9 years ago

24% is chance. Something is wrong with your training, look at the log, is the loss decreasing, is the validation accuracy increasing? If not, fix it.

shelhamer commented 9 years ago

Please ask on the caffe-users group.