# How to implement an artificial network that outputs an integer within a range?

The goal is to implement an artificial network that, based on training samples labelled with positive integers, outputs a positive integer.

Perhaps I am not searching for the correct thing but all the examples I have found have shown classifiers using a sigmoid function that outputs a fixed or floating point number within the range $$<0 \to 1>$$.

Any point in the right direction or python/toy code would be very appreciated!

• Use relu or leaky relu.. – DuttaA Sep 11 '18 at 5:16

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

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

I'm not really sure if you want the NN 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 nevron(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).

Hope this helps. Provide some more details if this didn't answer your question.

• Thank you. I probably should have phrased my question better. And thank you for correcting me on the sigmoid function that completely slipped my mind. To clarify yes I do want a regressor. I am fairly new to this forgive me for my ignorance. – Jess Bullard Sep 10 '18 at 23:28
• This method will probably not solve non linear regressions – DuttaA Sep 11 '18 at 8:04
• @DuttaA After doing a quick search relu would probably be best for this scenario. If you have a more complete answer please make an answer. – Jess Bullard Sep 11 '18 at 13:08
• @JessBullard I have not done any regression but I think user NeilSlater or johnDoucette can provide an answer..You can request them...Also relu is for the hidden layers only since it outputs only positive values..At the final layer you have to use the aforementioned method.. – DuttaA Sep 11 '18 at 13:13
• @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/… – Neil Slater Sep 12 '18 at 11:14