Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-layer neural network won't predict negative values

I have implemented a multilayer perceptron to predict the sin of input vectors. The vectors consist of four -1,0,1's chosen at random and a bias set to 1. The network should predict the sin of sum of the vectors contents.

eg Input = <0,1,-1,0,1> Output = Sin(0+1+(-1)+0+1)

The problem I am having is that the network will never predict a negative value and many of the vectors' sin values are negative. It predicts all positive or zero outputs perfectly. I am presuming that there is a problem with updating the weights, which are updated after every epoch. Has anyone encountered this problem with NN's before? Any help at all would be great!!

note: The network has 5inputs,6hidden units in 1 hidden layer and 1 output.I am using a sigmoid function on the activations hidden and output layers, and have tried tonnes of learning rates (currently 0.1);

like image 677
B. Bowles Avatar asked Feb 24 '11 14:02

B. Bowles


People also ask

Can neural network predicting negative values?

Multi-layer neural network won't predict negative values.

Can neural networks have negative weights?

Weights can be whatever the training algorithm determines the weights to be. If you take the simple case of a perceptron (1 layer NN), the weights are the slope of the separating (hyper)plane, it could be positive or negative.

What should I do when my neural network does not learn?

First, build a small network with a single hidden layer and verify that it works correctly. Then incrementally add additional model complexity, and verify that each of those works as well. Too few neurons in a layer can restrict the representation that the network learns, causing under-fitting.


Video Answer


1 Answers

Being a long time since I looked into multilayer perceptrons hence take this with a grain of salt.

I'd rescale your problem domain to the [0,1] domain instead of [-1,1]. If you take a look at the logistic function graph:

enter image description here

It generates values between [0,1]. I do not expect it to produce negative results. I might be wrong, tough.

EDIT:

You can actually extend the logistic function to your problem domain. Use the generalized logistic curve setting A and K parameters to the boundaries of your domain.

Another option is the hyperbolic tangent, which goes from [-1,+1] and has no constants to set up.

like image 124
Vitor Py Avatar answered Oct 31 '22 17:10

Vitor Py