0
$\begingroup$

I have a neural network with an Input layer, 2 hidden Dense layers and an Output layer.

I would like for each neuron in the Output layer to give me a number between 0 and 2 (either 0, 1 or 2), like so:

NN

If I use a neuron for each possibility (a neuron for 0, a neuron for 1 and another for 2) and then pick the one with the best prediction, the output layer length would be far too much.

Is there a way to implement this ? (I am fairly new to neural networks and the like)

$\endgroup$

1 Answer 1

1
$\begingroup$

There are two ways to do that:

  1. Scale your output data from [0, 2] to [0, 1] and apply Sigmoid activation at the end.

  2. Make your own custom activation function that output everything in [0, 2]

I strongly suggest you no. 1, it's way faster to implement.

$\endgroup$
7
  • $\begingroup$ Thank you so much for your answer :) Could you kindly provide me with an example implementation (tutorial or the like) of such approach (approach number 1 or 2 or both) $\endgroup$
    – Ness
    Apr 8, 2021 at 14:04
  • 1
    $\begingroup$ I think you don't need a whole tutorial, just apply a basic Min-Max scaler on your Y data to implement method 1. If your Y data already is in [0, 2] then just do: y = y/2 to get it in [0,1]. Alternatively, lots of people use sklearn's MinMaxScaler. $\endgroup$
    – Leevo
    Apr 8, 2021 at 14:11
  • 1
    $\begingroup$ Alrighty then, thank you so much :) $\endgroup$
    – Ness
    Apr 8, 2021 at 14:11
  • 1
    $\begingroup$ NP, remember to scale the data back one you're done training! :) $\endgroup$
    – Leevo
    Apr 8, 2021 at 14:28
  • $\begingroup$ But doesn't this look like a classification problem ? The suggested solution seems to convert it into a regression. $\endgroup$ Apr 8, 2021 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.