I would like to create a neural network, which, given the training data (e.g. 58, 2) outputs a non-binary number (e.g 100). Perhaps I am not searching for the correct thing, but all the examples I have found have shown classifiers using a sigmoid function (range of 1 to 0). I am looking for something that would output nonbinary numbers.


1 Answer 1


First of all, sigmoid does not output 0 or 1, it outputs any real number in the range between 0 and 1.

Furthermore, neural networks don't usually output binary values, unless the output layer uses the step function as an activation function (which is rare).

I'm not really sure if you want the neural network to be a classifier or regressor, but it sounds like you want a regressor.

Regression is when you are interested in the value of the output neuron(s) itself. A simple example is if you want the network to predict the sum of two input neurons.

If you want to change the network from a classifier to a regressor you should probably reduce the number of neurons in the output layer to 1, and change the activation function of that neuron from softmax to the identity function ($f(x)=x$; which is the same as no activation function at all).

  • $\begingroup$ @JessBullard: This answer is accurate. Generally for regression problems you would use a linear output at the final layer, and mean squared error for the loss function. You would still use non-linear in the hidden layers. Example in Keras: machinelearningmastery.com/… $\endgroup$ Sep 12, 2018 at 11:14
  • $\begingroup$ @NeilSlater I looked at the code presented in the link. That appears to be similar to what I am looking for. How would I get it to output it's prediction given an input? I've seen many questions about this in the comments of his post but no solution has worked. $\endgroup$ Sep 13, 2018 at 1:12
  • $\begingroup$ @JessBullard: that should just be model.predict See the Keras documentation here: keras.io/models/model $\endgroup$ Sep 13, 2018 at 6:14
  • $\begingroup$ @NeilSlater I do that but then it expects shape2 but was given shape1. All the solutions I've found have not worked. $\endgroup$ Sep 13, 2018 at 13:01
  • $\begingroup$ @JessBullard: That is a mistake when using it. Probably you are passing in a single example and it expects an array of examples. If you cannot figure that out, ask a question on Data Science or Stack Overflow showing the relevant part of your code and the error message you get. Note this has probably already been answered multiple times on both sites, so try searching your goal and error message there first. $\endgroup$ Sep 13, 2018 at 13:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .