2

我正在尝试编写一个简单的神经网络,它可以为 y=x 函数提供权重。这是我的代码: http ://codepad.org/rPdZ7fOz

如您所见,错误级别从未真正下降太多。我尝试改变动量和学习率,但没有太大帮助。我的输入、隐藏和输出数量是否适合我想要做的事情?如果不是,应该是什么?如果是这样,还有什么可能是错的?

4

1 回答 1

2

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.

于 2010-09-05T15:41:16.490 回答