vlfeat / matconvnet

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

Binary Classification #681

Open epam20 opened 8 years ago

epam20 commented 8 years ago

Hi,

Is there any possibility of adding a binary classification problem in the examples folder of this library? Many people have issues with this subject, I have my own, couldn't find anything in here or on stackoverflow about this library and binary classification. I was about to write a 2-page monologue complaining about a lot of things about this topic, but I would like to try asking politely first, if there is any chance you can add an example that tries to solve a binary classification problem?

I am implementing a CNN which tries to predict the direction (left or right) of the shadow of an object as seem by the camera. I use labels [-1 and 1], errorFunction 'binary', 16k training images, half of each for each label. and 2k validation images, half of each for each label too. There's no batch normalization, learning rate is 0.01, number of epochs is 40, Input images are 128x128 single channel (greyscale) with their mean deducted from them. The network is initialized as shown below:

untitled

Why am I getting these kinds of results then for all epochs? I am not sure what am I doing wrong.

train: epoch 01: 1/134: 21.3 (21.3) Hz binerr: 51.440 objective: 0.000 train: epoch 01: 2/134: 21.9 (22.6) Hz binerr: 50.620 objective: 0.000 train: epoch 01: 3/134: 22.7 (22.8) Hz binerr: 50.440 objective: 0.000 train: epoch 01: 4/134: 22.7 (23.0) Hz binerr: 50.375 objective: 0.000 train: epoch 01: 5/134: 22.9 (23.6) Hz binerr: 50.316 objective: 0.000 train: epoch 01: 6/134: 22.8 (22.5) Hz binerr: 50.267 objective: 0.000 train: epoch 01: 7/134: 22.8 (22.5) Hz binerr: 50.229 objective: 0.000 train: epoch 01: 8/134: 22.9 (23.3) Hz binerr: 49.953 objective: 0.000 train: epoch 01: 9/134: 22.9 (23.1) Hz binerr: 49.953 objective: 0.000 train: epoch 01: 10/134: 22.9 (23.4) Hz binerr: 49.966 objective: 0.000 train: epoch 01: 11/134: 23.0 (24.0) Hz binerr: 50.033 objective: 0.000 train: epoch 01: 12/134: 23.1 (23.9) Hz binerr: 50.010 objective: 0.000 train: epoch 01: 13/134: 23.1 (23.8) Hz binerr: 49.982 objective: 0.000 train: epoch 01: 14/134: 23.2 (23.7) Hz binerr: 49.926 objective: 0.000 train: epoch 01: 15/134: 23.2 (23.5) Hz binerr: 49.967 objective: 0.000 train: epoch 01: 16/134: 23.2 (23.4) Hz binerr: 49.969 objective: 0.000 train: epoch 01: 17/134: 23.2 (23.3) Hz binerr: 49.966 objective: 0.000 train: epoch 01: 18/134: 23.2 (23.5) Hz binerr: 49.963 objective: 0.000 train: epoch 01: 19/134: 23.2 (23.1) Hz binerr: 50.017 objective: 0.000 train: epoch 01: 20/134: 23.3 (24.0) Hz binerr: 50.010 objective: 0.000 train: epoch 01: 21/134: 23.3 (23.8) Hz binerr: 50.011 objective: 0.000 train: epoch 01: 22/134: 23.3 (23.1) Hz binerr: 50.011 objective: 0.000 train: epoch 01: 23/134: 23.3 (23.4) Hz binerr: 50.017 objective: 0.000

Also, since my labels are -1 and 1, then what do net.meta.classes.name represent and what do imdb.meta.classes represent also? are these used for indexing? or should these two values be -1 and 1 as well. I am referring to the data that is created by the function:

net.meta.classes.name = arrayfun(@(x)sprintf('%d',x),1:2,'UniformOutput',false) ;

I am not sure what's wrong with my network, Could the problem be in how the network is set up? I would like to ask or your input.

Could I ask if it's possible the matconvnet library come with a working example of a CNN with binary classification as it's main problem soon?

iiwindii commented 8 years ago

try the labels 1 and 2

epam20 commented 8 years ago

i tried that as well with a softmaxloss and setting my errorfunction as multiclass, but the results are similar

iiwindii commented 8 years ago

check if all the samples are classified into one class because the error is 50% all the same

Addhi86 commented 7 years ago

@fengyunxiaozi Can you please tell what BinErr shows?

H-Seyf commented 7 years ago

@epam20 Hello; were you able to solve the problem? have you used the demos (MNIST,CIFAR,IMAGENET)? which one? Do you use Gray-Scale images or RGB Images?

iiwindii commented 7 years ago

@Addhi86 BinErr is the clasification error. However,BinErr of each batch showed above is about 0.5, so I guess if all the samples are classified into one class.