Giter Club home page Giter Club logo

Comments (13)

lenck avatar lenck commented on May 7, 2024

Hi, based on the cnn_train.m example for training, you need to have labels +-1. But as it is an example training code, there is nothing easier to change the line 274 in cnn_train.m to:

 error = bsxfun(@eq, predictions, labels);

And then you should be able to use 1,2 labels. It's just that it is sort of a common practice to have binary task with labels +-1...

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

I see. Great. Thanks!

from matconvnet.

lenck avatar lenck commented on May 7, 2024

Hmm, I just realised that I got it slightly wrong :)
With the binary classification, the network actually has a single output - that's why you multiply with the label directly...
But I just found, that actually having 2-class softmax is the same as logistic regression so in order to use what I've proposed, you will need to have softmaxloss layer at the end with two outputs. But that might have actually been your case, so I hope that it worked :)

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

Hmm, so should I still use -1/+1?

from matconvnet.

lenck avatar lenck commented on May 7, 2024

I think the easiest would be to use the softmax with two outputs and two labels 1 and 2, then you just need to remove the top5 error evaluation in updateError in cnn_train (as you will have just 2 labels)...

It's actually worth to fix this - to be able to set the n for the error measures...

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

Great. Or actually I have data only with 2 labels (1 or 2) and I still set my output as having 5 distinct labels to train the network. I think this will still be ok, am I right?

from matconvnet.

lenck avatar lenck commented on May 7, 2024

Hmm, I'm not sure. At least the last layer would be slower, because you would have more parameters to learn (in this case to learn that they should be zero) - so you would deliberately make your problem more complicated.
But it's really just about commmenting out lines {271, 272} in cnn_train.m :)

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

ok, great! Thanks.

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

I comment the {271,272} lines and keep label as 1/2, the output of the error plot look weird to me (it bigger than 1!?)

screenshot from 2015-01-28 14 41 11

from matconvnet.

cheer37 avatar cheer37 commented on May 7, 2024

have you solved your problem?
I did binary classification with binary train type and 1/-1 labels.
But result doesn't make sense and graph is like you.
So, i did train with multiclass type and 1/2 labels.
But it does not converge.
How did you deal with binary classification with matconvnet?

from matconvnet.

anewlearner avatar anewlearner commented on May 7, 2024

@lenck
I did just as what you said,but things seems to be wrong.
In cifar, I changed the 10 in penultimate layers to be 2, and have the labels of 1,2. but the error didn't change in epochs. It always be obj:0.693 top1err:0.501.
I also tried to use the lables of -1 and 1. And change the error to 'error = bsxfun(@eq, predictions, labels);' But I just get a large error such as 150.
Look forward to your reply!
Thanks!

from matconvnet.

Addhi86 avatar Addhi86 commented on May 7, 2024

@johnny5550822 @lenck It would be helpful for many others to answer how solve Binary classification?

from matconvnet.

johnny5550822 avatar johnny5550822 commented on May 7, 2024

@Addhi86 Sorry, I have not used matconvnet for a while. Not sure how to handle this.

from matconvnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.