Java Encog Project Hangs While Learning

guptashubham123's picture

Hi,

I have coded java project to predict stock market using Encog Neural Network. It is actually the java adaptation of this project in c# http://www.heatonresearch.com/encog/articles.html.

The problem is when i obtain data it works fine but when i click on train network a window opens and the program hangs without any error or exception. Can someone help me on it ?

Here is my code for ref : http://sites.google.com/site/javatestneo/java/StockPredict.zip

SeemaSingh's picture

Which method call is hanging? Is it hanging inside of Encog or elsewhere.

I tried to compile your app, but I get lots of errors on:

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;

If you could give me a small code segment that hangs that does not use any third party libs I can check. It could very well be that your GUI code is hanging as well.

gshank's picture

I have one network with 3 input, 6 hidden, 3 output that seems to work great but I have another network with just 1 input, 2 hidden, 1 output that hangs during train.iteration() and I have no idea why. I use the same code for both networks but the neurons created/used are just a variable so I either pass 3 or 1. It does not hang right away, it will usually run for at least 10 minutes before hanging. Here is my training loop code:

Train train = new Backpropagation(network, new BasicNeuralDataSet(input, ideal), 0.001, 0.1);
int cnt = 0;
long timer = System.currentTimeMillis();
boolean isFirst = true;
double error = 0;
double lastError = 0;
java.io.File f = new java.io.File("done");
if ( f.exists() ) f.delete();
System.out.println("Training started: "+new Date().toString());
do {
train.iteration();
error = train.getError();
if ( isFirst ) {
System.out.println(cnt+" Error: "+error);
isFirst = false;
lastError = error;
}
if ( (System.currentTimeMillis()-timer) > 59999 ) {
cnt++;
System.out.println(cnt+" Error: "+error+" diff="+(lastError - error));
lastError = error + 1;
timer = System.currentTimeMillis();
}
} while ( error > 0 && !f.exists() );
train.finishTraining();
System.out.println("Training finished: "+new Date().toString());
System.out.println("last error="+error);


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.