I'm new to Machine Learning and I'm working on a a Java application that classifies an object using its image. I have 40 input neurons and n output neurons(dependent on the number of training data). I used Encog as a framework for my Neural Network. I was able to successfully train the data but as I test the network, it does not seem to work well. It cannot classify the objects correctly. Here's for the training part:
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(null,true,i));
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,h));
network.addLayer(new BasicLayer(new ActivationSigmoid(),false,o));
network.getStructure().finalizeStructure();
network.reset();
// train the neural network
final Backpropagation train = new Backpropagation(network, trainingSet, lr, 0.3);
train.fixFlatSpot(false);
w = new SwingWorker(){
@Override
protected Object doInBackground() throws Exception {
// learn the training set
int epoch = 1;
do {
train.iteration();
//System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
} while(train.getError() > me && !isStop);
isStop = false;
return null;
}
};
w.execute();
and the testing part:
BasicNetwork network = (BasicNetwork) SerializeObject.load(new File("file/Weights.ser"));
MLData input = new BasicMLData(inputCount);
input.setData(in);
MLData output = network.compute(input);
for(int y = 0; y < output.size(); y++){
System.out.println(output.getData(y));
}
Is there something wrong with the training part? I do hope someone could guide me if I'm doing things the right way.
Do you mean that when you try to recognize the exact same data that you trained on you cannot recognize it? If this is the case then I would assume that there is some difference in the way that you are encoding the images for testing vs training.
If you are seeing bad results on data that is different than what you trained with, this is a different (and common) problem. It means that the training data is perhaps not representative of the entire problem space. i.e. the new data that you are using is different enough from the training data that no match is being made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With