简体   繁体   English

C#Encog神经网络 - 尽管神经网络的整体误差很小,但预期输出与实际误差相差甚远

[英]C# Encog Neural Network - Expected output is very far off actual error despite low overall error of neural network

I've been trying to get Encog going for a few days now. 我一直试图让Encog继续几天。

My data consists of 4 input variables (between 1 and 1000), and 1 output variable (between -30 and 30). 我的数据包括4个输入变量(介于1和1000之间)和1个输出变量(介于-30和30之间)。 I am training with around 50,000 rows of data. 我正在训练大约50,000行数据。

The data is normalised (between -1 and 1 for the tanh activation function), before passing it into a neural network with the following structure and training: 数据被标准化(tanh激活函数在-1和1之间),然后将其传递到具有以下结构和训练的神经网络:

 Network.AddLayer(new BasicLayer(null, true, 4));
 Network.AddLayer(new BasicLayer(new ActivationTANH(), true, 8));
 Network.AddLayer(new BasicLayer(new ActivationTANH(), false, 1));
 Network.Structure.FinalizeStructure();
 Network.Reset();

 IMLDataSet trainingData = new BasicMLDataSet(Input.ToArray(), ExpectedOutput.ToArray());

 IMLTrain train = new ResilientPropagation(Network, trainingData);

 int epoch = 1;

 do
 {
     train.Iteration();
     Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
     epoch++;
 } while (train.Error > 0.024);

The program then outputs each row's expected output along with the actual output from the neural network. 然后程序输出每一行的预期输出以及神经网络的实际输出。 Here is a screenshot of the output (a few rows): http://i.imgur.com/UVWCOis.png 以下是输出的屏幕截图(几行): http//i.imgur.com/UVWCOis.png

As you can see, the error (which is the average error of the neural network for all of the rows) must be below 0.024 before this output is printed. 如您所见,在打印此输出之前,错误(所有行的神经网络的平均误差)必须低于0.024。 But many of the expected and actual outputs have a huge amount of error. 但是许多预期和实际产出都有很大的误差。

I believe that the neural network is not sensitive enough to the propagation. 我相信神经网络对传播不够敏感。 It seems that the actual outputs of the neural network are all very close together, I believe because they haven't deviated far from the initial random weights. 似乎神经网络的实际输出都非常接近,我相信因为它们没有偏离初始随机权重。

Can anyone suggest how I can fix this? 任何人都可以建议我如何解决这个问题?

I have tried reducing the size of the inputs (I used 50), I also tried removing biases, and both of these lead to a similar result. 我试过减小输入的大小(我使用了50),我也试过去除偏差,这两者都导致了类似的结果。

Without seeing your data I cannot really say where the discrepancy is coming from. 在没有看到您的数据的情况下,我无法真正说出差异的来源。 I suspect some of the data elements have much higher errors than others. 我怀疑一些数据元素的错误要比其他元素高得多。 If you use this method, it will give you the detail for how the error is calculated and what the "current error" is at each element as it progresses through your data. 如果您使用此方法,它将为您提供有关如何计算错误的详细信息以及每个元素在数据进展过程中的“当前错误”。 This will generate quite a bit of output if your data set is large. 如果您的数据集很大,这将产生相当多的输出。

    public static void errorDiagnostic(BasicNetwork network, MLDataSet dataSet) {
    int count = 0;
    double totalError = 0;

    System.out.println("Network error: " + network.calculateError(dataSet));


    for(MLDataPair pair : dataSet) {
        MLData actual = network.compute(pair.getInput());
        System.out.println("Evaluating element " + count + " : " + pair.getInput().toString());

        for(int i=0;i<pair.getIdeal().size();i++) {
            double delta = Math.abs(actual.getData(i) - pair.getIdeal().getData(i));
            totalError += delta*delta;
            count++;
            double currentError = totalError/count;
            System.out.println("\tIdeal: " + pair.getIdeal().getData(i) + ", Actual: " + actual.getData(i) + ", Delta: " + delta + ", Current Error: " + currentError);

        }
    }
}

For example, the output for a trained XOR (from the Encog hello world app) is: 例如,训练有素的XOR(来自Encog hello world app)的输出是:

    Network error: 0.009643582111728128
Evaluating element 0 : [BasicMLData:0.0,0.0]
    Ideal: 0.0, Actual: 0.10384251352940682, Delta: 0.10384251352940682, Current Error: 0.01078326761610504
Evaluating element 1 : [BasicMLData:1.0,0.0]
    Ideal: 1.0, Actual: 0.9109458503325736, Delta: 0.08905414966742642, Current Error: 0.009356954594546711
Evaluating element 2 : [BasicMLData:0.0,1.0]
    Ideal: 1.0, Actual: 0.8914073581830911, Delta: 0.10859264181690886, Current Error: 0.01016875701528963
Evaluating element 3 : [BasicMLData:1.0,1.0]
    Ideal: 0.0, Actual: 0.08982236581744897, Delta: 0.08982236581744897, Current Error: 0.009643582111728128

This lets you see the degree to which each element is contributing to the error. 这使您可以查看每个元素对错误的贡献程度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM