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

assertition failed vl_simplenn.m #34

Closed
StevenLOL opened this issue Jan 1, 2015 · 3 comments
Closed

assertition failed vl_simplenn.m #34

StevenLOL opened this issue Jan 1, 2015 · 3 comments

Comments

@StevenLOL
Copy link

Hi,

After run cnn_mnist.m, I have few net-epoch-n.mat models.

To predict one image on mnist , following the example in http://www.vlfeat.org/matconvnet/pretrained

When calling

net=load('./data/mnist-baseline/net-epoch-5.mat');
res=vl_simplenn(net.net, im); % im is just one mnist image whose size is 28*28

I got the error:

Error using vl_nnsoftmaxloss (line 42) Assertion failed.
Error in vl_simplenn (line 164)
res(i+1).x = vl_nnsoftmaxloss(res(i).x, l.class) ;

@lenck
Copy link
Contributor

lenck commented Jan 2, 2015

Hi, when you train a model, as a last layer there is usually the softmaxloss which is a softmax followed by logistic loss - the loss which is being optimized. But in order to compute the loss, it needs the ground truth in net.layers{end}.class which is passed as the second parameter in vl_simplenn to vl_nnsoftmaxloss.

However, in general when you want to obtain only class probabilities, you simply change the last layer type to:

net.net.layers{end}.type = 'softmax';

And now your call of vl_simplenn should work...

@StevenLOL
Copy link
Author

Thanks, the best CNN toolkit ever.

vedaldi pushed a commit that referenced this issue Aug 16, 2017
fixes small typos

Approved-by: Karel Lenc <lenckarel@gmail.com>
Approved-by: Joao Henriques <jotaf98@hotmail.com>
@rng1995
Copy link

rng1995 commented Oct 13, 2017

Where should place the command
net.net.layers{end}.type = 'softmax'; ? Is it in cnn_cifar.m file or cnn_cifar_init.m or vl_simplenn.m file ?

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

3 participants