views:

69

answers:

1

Hello everyone. I am trying to write a simple neural network that can come up with weights to for, say, the y=x function. Here's my code: http://codepad.org/rPdZ7fOz

As you can see, the error level never really goes down much. I tried changing the momentum and learning rate but it did not help much. Is my number of input, hidden and output correct for what I want to do? If not, what should it be? If so, what else could be wrong?

+2  A: 

You're attempting to train the network to give output values 1,2,3,4 as far as I understood. Yet, at the output you use a sigmoid (math.tanh(..)) whose values are always between -1 and 1.

So the output of your Neural network is always between -1 and 1 and thus you always get a large error when trying to fit output values outside that range.

(I just checked that when scaling your input and output values by 0.1, there seems to be a nice training progress and I get at the end:

error 0.00025

)

The Neural Network you're using is useful if you want to do classification (e.g. assign the data point to class A if the NN output is < 0 or B if it is > 0). It looks like what you want to do is regression (fit a real-valued function).

You can remove the sigmoid at the output node but you will have to slightly modify your backpropagation procedure to take this into account.

Andre Holzner