Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getError() returns the error before the last iteration #10

Closed
gnitr opened this issue Aug 14, 2011 · 1 comment
Closed

getError() returns the error before the last iteration #10

gnitr opened this issue Aug 14, 2011 · 1 comment
Milestone

Comments

@gnitr
Copy link

gnitr commented Aug 14, 2011

TrainFlatNetworkResilient.getError() returns the error measured before the last call to TrainFlatNetworkResilient.train().

It would be nice to document that behaviour in the function as it can be surprising.

You can observe the issue by replacing the end of XORFlat.ava with this block. You'll see that the mse is different from the one displayed with getError after the the last iteration.

    double[] output = new double[1];
    // test the neural network
    System.out.println("Neural Network Results:");
    double mse = 0;
    for(MLDataPair pair: trainingSet ) {
        double[] input = pair.getInput().getData();
        network.compute(input, output);
        System.out.println(input[0] + "," + input[1] + ":" + output[0]);
        mse += (output[0] - pair.getIdeal().getData()[0]) * (output[0] - pair.getIdeal().getData()[0]); 
    }
    System.out.println("MSE: "+(mse / trainingSet.getRecordCount()));
    train.iteration();
    System.out.println("Error: "+train.getError());

Since your stopping condition in XORFlat.java is based on getError() it actually runs one unnecessary iteration. So this type of construct is a bit misleading because in some cases the MSE can increase from one epoch to the next and the actual MSE of the network when you leave the loop might not meet the stopping condition. However in general I don't think it will make a huge difference though.

@ghost ghost assigned seemasingh Aug 29, 2011
@seemasingh
Copy link
Contributor

Good point! I added a better comment to Encog 3.1. This has been checked in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants