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

How to feed labels into classifier network #97

Open
velociwabbit opened this issue Feb 10, 2018 · 1 comment
Open

How to feed labels into classifier network #97

velociwabbit opened this issue Feb 10, 2018 · 1 comment

Comments

@velociwabbit
Copy link

I am really enjoying learning convnet.js and have had some success with your regression models. Congrats to the developers.

However It is unclear how to provide labels for classification. I am using a very simple network (see below)

These are the layers and trainer and if you notice i have passed a 3 dimensional array (i am acually using 10 representing 0-9 digits)

But the trainer iterates as if the y value input is an integer and does a comparison i === y which can never be true in the backward method.

How do you pass 10 labeled binary outputs to the training function?

Also the output of the training function has a cost_loss and loss value which are the same but what does it mean? the loss value can range from a high of 2 or 4 to low of .03... so it is not a % accuracy number... what does it mean and how do i convert it to % accuracy?

Thanks

net.makeLayers(  [  {   type:'input'    , out_sx:1, out_sy:1, out_depth:4} 
                  , {   type:'fc'       , num_neurons:8, activation:'sigmoid' } 
                  , {   type: 'softmax' , num_classes: 3}])
trainer = new convnetjs.SGDTrainer(net, {learning_rate : 0.01, momentum: 0.0, batch_size: 1, l2_decay: 0.001});

for(var i=0;i< xtrain.length;i++) {
              x.w[0] = (traindata[i][1]-66) / 40
              x.w[1] = (traindata[i][2]-66) / 40
              x.w[2] = (traindata[i][3]-66) / 40
              x.w[3] = (traindata[i][4]-66) / 40

              var stats = trainer.train(x, [ytrainz[i]/ 10, ytrainy[i]/ 10, ytrainx[i] /10])
@NoamGaash
Copy link

Hi.
Please note the network assumes that each training example has a single class.
Therefore, trainer's Y argument sould contain a single integer, representing the class number (in your case - 0, 1 or 2)

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

2 participants