1

I tried to train my own neural net using my own imagedatabase as described in

http://caffe.berkeleyvision.org/gathered/examples/imagenet.html

However when I want to check the neural net after training on some standard images using the matlab wrapper I get the following output / error:

Done with init
Using GPU Mode
Done with set_mode
Elapsed time is 3.215971 seconds.
Error using caffe
Invalid input size

I used the matlab wrapper before to extract cnn features based on a pretrained model. It worked. So I don't think the input size of my images is the problem (They are converted to the correct size internally by the function "prepare_image").

Has anyone an idea what could be the error?

mcExchange
  • 6,154
  • 12
  • 57
  • 103
  • Please post the Matlab code to reproduce the issue – krisdestruction Apr 22 '15 at 18:20
  • I can pass the Matlab-Code later. But in principal it's just the standard "matcaffe_demo.m" file where I only adapted the 2 paths (1) to my self trained caffemodel file and (2) to the corresponding prototxt-file. I must admit that i didn't change the path to the image-mean file, which is called by "prepare_image". That's because the image-mean I computed myself is in a "binaryproto" format and not in a ".mat" format as required by Matlab. While training the net I had to reduce the "batch size" due to memory issues. I hope thats not causing the problem. – mcExchange Apr 23 '15 at 09:19
  • The code of matcaffe_demo breaks exactly when trying to compute the scores for the image ("scores = caffe('forward', input_data);"). Everything before seems to work fine (initialisation by "matcaffe_init(use_gpu, myOwnModel_def_file, myOwnModel_file)") – mcExchange Apr 23 '15 at 09:26

1 Answers1

2

Found the solution: I was referencing the wrong ".prototxt" file (Its a little bit confusing because the files are quite similar. So for computing features using the matlab wrapper one needs to reference the following to files in "matcaffe_demo.m":

models/bvlc_reference_caffenet/deploy.prototxt
models/bvlc_reference_caffenet/MyModel_caffenet_train_iter_450000.caffemodel

where "MyModel_caffenet_train_iter_450000.caffemodel" is the only file needed which is created during training.

In the beginning I was accidently referencing

models/bvlc_reference_caffenet/MyModel_train_val.prototxt

which was the ".prototxt" file used for training.

mcExchange
  • 6,154
  • 12
  • 57
  • 103