Transforming our NN from binary to 3-class classifier

Can anyone point me in the direction of how to approach this problem?

I have a dataset with labels -1, 0 and 1.

My only idea is to use use tanh to output labels -1, 0 and 1.
But I wouldn’t know how to change the cost function, since it depends on labels being 0 and 1.
Also the 0 region of tanh is too small compared to -1 and 1. So i’m out of ideas here.

Hope I chose the right category to ask this question.
Thanks for any help.

Have you seen this link? Even thought the problem is for images, it deals with multiclass classification.

That is very useful. Thank you.

I would still like to learn how to do it using my own functions though.

Sure. Here are some hints:

  1. Construct your NN with the last layer as a Dense layer with number of classes (3 in your case).
  2. Your labels are -1, 0 and 1. As you might have guessed, -1 cannot be predicted by the neural network since the minimum index is 0. So, make your labels 0, 1, 2 i.e. increase them by 1.
  3. If you are following the tensorflow link to create the model, rest should be straight forward.

The underlying function in play here is softmax. Hence the use of from_logits=True in the loss function since the final layer activation function is linear.