1

我开始使用神经网络。我已经修改了为我自己的目的提供的 XOR 示例,但是当我运行它时,错误永远不会改变。

我试图近似的函数需要 4 个双精度并输出 1 个双精度,4 个输入始终为正,输出可以为负或正(多数为正)。对于初学者,我使用 50 条记录来训练数据。

工作异或(每次迭代都会减少错误)

    public static double[][] XORInput = {
        new[] {0.0, 0.0},
        new[] {1.0, 0.0},
        new[] {0.0, 1.0},
        new[] {1.0, 1.0}
    };

    public static double[][] XORIdeal = {
        new[] {0.0},
        new[] {1.0},
        new[] {1.0},
        new[] {0.0}
    };

    BasicNetwork network = new BasicNetwork();
    network.AddLayer(new BasicLayer(null, true, 2));
    network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
    network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
    network.Structure.FinalizeStructure();
    network.Reset();

    IMLDataSet trainingData = new BasicMLDataSet(XORInput, XORIdeal);

    IMLTrain train = new ResilientPropagation(Network, trainingData);

不工作(错误永远不会消失):

    BasicNetwork network = new BasicNetwork();
    network.AddLayer(new BasicLayer(null, true, 4));
    network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 6));
    network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
    network.Structure.FinalizeStructure();
    network.Reset();

    IMLDataSet trainingData = new BasicMLDataSet(myInput, myExpectedOutput);

    IMLTrain train = new ResilientPropagation(Network, trainingData);

训练数据的一些样本记录:

    Input:          
    2.54, 3.15, 3.4, 1.73
    5.3, 1.78, 3.9, 2.04
    1.71, 5.4, 4.3, 2.26
    1.62, 6.4, 4, 1.89
    1.45, 8.4, 5.2, 2.14

    Output:
    5.59
    11.05
    6.89
    10.4
    -0.56

我认为问题在于激活功能没有触发。我认为这可能是因为 ActivationSigmoid() 不适合这个问题,但我尝试了 ActivationTANH() 得到完全相同的结果。

4

1 回答 1

3

问题是我的价值观没有被规范化。

要使用激活函数,您的所有输入和输出必须介于 1 和 0 (ActivationSigma) 和 -1 和 1 (ActivationTANH) 之间。您需要一些函数来将您的值标准化为它们需要的范围。

这个链接对我有很大帮助:

http://www.heatonresearch.com/wiki/Range_Normalization

于 2014-04-03T06:18:57.500 回答