vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 753 forks source link

Issues with multiclass training #214

Open arjun-mani opened 9 years ago

arjun-mani commented 9 years ago

Hi,

I've been attempting to use matconvnet in a project I'm working on. The training set consists of 10800 52X52 images, and there are three classes. I am using 25% of the data as a validation set, so at a batch size of 100, there are (0.75 * 10800) / 100 = 81 batches.

However, when I run cnn_train on the training set, I get the following error (train_cnn is a function I wrote to do some pre-processing and then call cnn_train):

Index exceeds matrix dimensions.

Error in cnn_train>error_multiclass (line 223) err(2,1) = sum(sum(sum(mass .* min(error(:,:,1:5,:),[],3)))) ;

Error in cnn_train>process_epoch (line 306) error = sum([error, [...

Error in cnn_train (line 141) [net,stats.train] = process_epoch(opts, getBatch, epoch, train, learningRate, imdb, net) ;

Error in train_cnn (line 30) net = cnn_train(net, imdb, @getBatch, 'batchSize', 100, 'numEpochs', 20, ...

I took a look at the specific section of the code that is giving me this error. In the error_multiclass function, the dimension of predictions is 1 X 1 X 3 X 100, while labels is 1 X 1 X 1 X 100. The @eq bsxfun operation yields an error matrix that is 1 X 1 X 3 X 100. However, the line that is giving me the error refers a depth of at least 5 in the third dimension, which obviously leads to this error. Is this a bug, or am I doing something wrong? I was able to get it working on mnist, which of course has >= 5 classes. Any help would be greatly appreciated.

bazilas commented 9 years ago

err(2,1) = sum(sum(sum(mass .* min(error(:,:,1:5,:),[],3)))) ;

this is the top-5 error, just change it to top-3 for your problem. it's not a bug.

V