Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on cnn_minst #51

Closed
amar2015 opened this issue Jan 26, 2015 · 12 comments
Closed

error on cnn_minst #51

amar2015 opened this issue Jan 26, 2015 · 12 comments

Comments

@amar2015
Copy link

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
Copy link
Author

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 vl_nnsoftmaxloss (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
Copy link
Contributor

lenck commented Jan 26, 2015

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
Copy link
Author

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
Copy link
Contributor

lenck commented Jan 26, 2015

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
Copy link
Author

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
Copy link
Author

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
Copy link

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
#51 (comment).

@amar2015
Copy link
Author

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
Copy link
Author

Should I change it before the training or after?

@felixachilles
Copy link

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
#51 (comment).



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
Copy link
Author

thank you so much, it worked out finally.

@mudassarkazmi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants