vlfeat / matconvnet

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

error on cnn_minst #51

Closed amar2015 closed 9 years ago

amar2015 commented 9 years ago

hi thanks a lot for offering that great tool box. I am trying to run cnn_mint but I have this error:

learning rate changed (0.000000 --> 0.001000): resetting momentum training: epoch 01: processing batch 1 of 600 ...Error using .* Array dimensions must match for binary array op.

Error in vl_nnsoftmax (line 30) Y = Y .* bsxfun(@minus, dzdY, sum(dzdY .* Y, 3)) ;

Error in vl_simplenn (line 211) res(i).dzdx = vl_nnsoftmax(res(i).x, res(i+1).dzdx) ;

Error in cnn_train (line 140) res = vl_simplenn(net, im, one, res, ...

Error in cnn_mnist (line 75) [net, info] = cnn_train(net, imdb, @getBatch, ...

I really appreciate it if you help to solve that error because I am trying to use the library to classify my own data.

amar2015 commented 9 years ago

I solved that problem but right now I have this error: learning rate changed (0.000000 --> 0.001000): resetting momentum training: epoch 01: processing batch 1 of 3 ... 0.11 s (874.0 images/s) err 85.0 err5 51.0 training: epoch 01: processing batch 2 of 3 ... 0.09 s (1122.3 images/s) err 87.0 err5 51.0 training: epoch 01: processing batch 3 of 3 ... 0.09 s (1113.6 images/s) err 88.3 err5 50.7 resuming by loading epoch 1 training: epoch 02: processing batch 1 of 3 ... 0.09 s (1055.9 images/s) err 87.0 err5 46.0 training: epoch 02: processing batch 2 of 3 ...Index exceeds matrix dimensions.

Error in vlnnsoftmaxloss (line 58) t = Xmax + log(sum(ex,3)) - reshape(X(c), [sz(1:2) 1 sz(4)]) ;

Error in vl_simplenn (line 163) res(i+1).x = vl_nnsoftmaxloss(res(i).x, l.class) ;

Error in cnn_train (line 140) res = vl_simplenn(net, im, one, res, ...

Error in cnn_mnist (line 118) [net, info] = cnn_train(net, imdb, @getBatch, ...

I guess because of bathes number does not fit with my data set. I have 300 training images. Would you please help me to choose the appropriate batch number.

lenck commented 9 years ago

This seems more like an error in the labels - softmax needs to have size(X,3) to be equal to number of classes, and also the labels must be among [1...NumClasses]. Isn't it possible that some of your labels are bigger than 2, considering that you are doing binary classification?

amar2015 commented 9 years ago

Thanks a lot for your quick response, I am not using binary classification I have 13 classes, so do you think I can not use it for multiple classes?

lenck commented 9 years ago

Sure you can, it's just that the last conv layer must have 13 filters (so that you get 13 responses) and your labels must be between 1..13 (so that the indexing X(c_) won't fail).

amar2015 commented 9 years ago

Thanks a lot I changed the last layer but I have this error now: Reference to non-existent field 'class'.

Error in vl_simplenn (line 163) res(i+1).x = vl_nnsoftmaxloss(res(i).x, l.class) ;

Error in cnn_mnist (line 125) res = vl_simplenn(net, im) ;

would you please help me to solve that error.

amar2015 commented 9 years ago

The training is working now but when I try test new image using vl_simplenn () I have this error : Error using vl_nnsoftmaxloss (line 42) Assertion failed.

Error in vl_simplenn (line 163) res(i+1).x = vl_nnsoftmaxloss(res(i).x, l.class) ;

Error in cnn_mnist (line 125) res = vl_simplenn(net, im) ; would you please help me to solve that error.

felixachilles commented 9 years ago

Change the last layer of your network from softmaxloss() to softmax() and compute the index of the largest element in the output vector, this is your classification result. On Jan 26, 2015 6:27 PM, "amar2015" notifications@github.com wrote:

The training is working now but when I try test new image using vl_simplenn () I have this error : Error using vl_nnsoftmaxloss (line 42) Assertion failed.

Error in vl_simplenn (line 163) res(i+1).x = vl_nnsoftmaxloss(res(i).x, l.class) ;

Error in cnn_mnist (line 125) res = vl_simplenn(net, im) ; would you please help me to solve that error.

— Reply to this email directly or view it on GitHub https://github.com/vlfeat/matconvnet/issues/51#issuecomment-71499754.

amar2015 commented 9 years ago

Thx , I did that but I have this error: learning rate changed (0.000000 --> 0.001000): resetting momentum training: epoch 01: processing batch 1 of 15 ...Error using .* Array dimensions must match for binary array op.

Error in vl_nnsoftmax (line 30) Y = Y .* bsxfun(@minus, dzdY, sum(dzdY .* Y, 3)) ;

Error in vl_simplenn (line 211) res(i).dzdx = vl_nnsoftmax(res(i).x, res(i+1).dzdx) ;

Error in cnn_train (line 140) res = vl_simplenn(net, im, one, res, ...

Error in cnn_mnist (line 118) [net, info] = cnn_train(net, imdb, @getBatch, ...

amar2015 commented 9 years ago

Should I change it before the training or after?

felixachilles commented 9 years ago

Only change it for testing. During training you always need a scalar loss output, like in vl_softmaxloss().

2015-01-26 18:40 GMT+01:00 amar2015 notifications@github.com:

Should I change it before the training or after?

— Reply to this email directly or view it on GitHub https://github.com/vlfeat/matconvnet/issues/51#issuecomment-71502184.



_Technische Universität München_Felix Achilles, M.Sc.* · Faculty of Informatics · Chair for Computer Aided Medical Procedures Boltzmannstr. 3 · *85748 Garching b. München · +49 (0)176 623 18 312

achilles@in.tum.de · campar.in.tum.de


amar2015 commented 9 years ago

thank you so much, it worked out finally.

mudassarkazmi commented 8 years ago

hi i am new to use CNN toolbox

i also have following error

learning rate changed (0.000000 --> 0.001000): resetting momentum training: epoch 01: processing batch 1 of 4 ...Error using .* Array dimensions must match for binary array op.

Error in vl_nnsoftmax (line 30) Y = Y .* bsxfun(@minus, dzdY, sum(dzdY .* Y, 3)) ;

Error in vl_simplenn (line 211) res(i).dzdx = vl_nnsoftmax(res(i).x, res(i+1).dzdx) ;

Error in cnn_train (line 140) res = vl_simplenn(net, im, one, res, ...

Error in reidentification (line 75) [net,info] = cnn_train(net, imdb, @getBatch, opts.train) ;


i dont know whats wrong with the following network

net.layers = {} ; % 1 conv1 net.layers{end+1} = struct('type', 'conv', ... 'filters', 1e-4*randn(5,5,3,32, 'single'), ... 'biases', zeros(1, 32, 'single'), ... 'stride', 1, ... 'pad', 2) ;

% 2 pool1 (max pool) net.layers{end+1} = struct('type', 'pool', ... 'method', 'max', ... 'pool', [3 3], ... 'stride', 2, ... 'pad', [0 1 0 1]) ;

% 10 ip1 net.layers{end+1} = struct('type', 'conv', ... 'filters', 0.1*randn(16,16,32,64, 'single'),... 'biases', zeros(1,64,'single'), ... 'filtersLearningRate', 1, ... 'biasesLearningRate', 2, ... 'stride', 1, ... 'pad', 0) ;

% 11 ip2 net.layers{end+1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,119, 'single'),... 'biases', zeros(1,119,'single'), ... 'filtersLearningRate', 1, ... 'biasesLearningRate', 2, ... 'stride', 1, ... 'pad', 0) ; % 12 loss

net.layers{end+1} = struct('type', 'softmax') ;

Please guide me in this regard I will be really thankful for this help