【发布时间】:2015-04-24 04:25:18
【问题描述】:
我正在实施一种反向传播算法。最初,我致力于训练我的网络以解决 XOR,以在将其用于我的设计之前验证它是否正常工作。阅读this 后,我决定先训练它解决与门。我使用 sigmoid 作为传递函数和 MSE 来计算总误差。我使用了介于 0.01 和 0.5 之间的不同学习率。我每次对网络进行几次不同的迭代训练,从 100 次迭代到 1000 次迭代。我得到的最小总误差是 0.08。这是可接受的错误吗?
我的第二个问题,我应该使用阈值而不是 sigmoid 来解决与门吗?如果是,合适的阈值是多少?
第三,我是否应该对初始权重设置一个限制,例如在 -1 和 1 之间?
提前致谢。
编辑 1
我认为输出很奇怪 这是第一次迭代后的输出:
Target: 0.0 Output: 0.5314680723170211
Target: 0.0 Output: 0.7098671414869142
Target: 0.0 Output: 0.625565435381579
Target: 1.0 Output: 0.7827456263767251
以及第 400 次迭代后的输出:
Target: 0.0 Output: 0.2826892072063843
Target: 0.0 Output: 0.4596476713717095
Target: 0.0 Output: 0.3675222634971935
Target: 1.0 Output: 0.5563197014845178
编辑 2
这是我的代码中进行反向传播的部分:
for( int i=0;i< currentLayer.getSize();i++)
{
temp = currentLayer.getAt(i);
err=temp.getOutput()*(1-temp.getOutput())*outErr[i];
temp.setError(roundTwoDecimals(err));
}
for ( int i=0;i<currentLayer.getSize();i++)
{
temp = currentLayer.getAt(i); // get a neuron at the output layer
// update the connections
for (int j=0 ;j<temp.getInConnections().size();j++)
{
inputCon= temp.getInputConnectionAt(j);
newW=inputCon.getWeight()+ inputCon.getDst().getError()*inputCon.getInput()*this.learningRate;
inputCon.setWeight(roundTwoDecimals(newW));
}
// now update the bias
temp.setBias(temp.getBias()+(this.learningRate*temp.getError()));
}
【问题讨论】:
标签: neural-network backpropagation