org.yccheok.numrecognition
Class NumberNeuralNetworkTrainer

java.lang.Object
  extended by org.yccheok.numrecognition.NumberNeuralNetworkTrainer
All Implemented Interfaces:
java.util.EventListener, org.joone.engine.NeuralNetListener

public class NumberNeuralNetworkTrainer
extends java.lang.Object
implements org.joone.engine.NeuralNetListener

This is the neural network used to perform training.


Field Summary
private  NumberImageFeatureFactory featureFactory
          Feature factory for this neural network.
private  org.joone.engine.SigmoidLayer hidden
          The hidden layer of neurons.
private  org.joone.engine.SigmoidLayer input
          The input layer of neurons.
private  org.joone.engine.Monitor monitor
          Monitor.
private  org.joone.engine.SigmoidLayer output
          The output layer of neurons.
private  org.joone.engine.FullSynapse t1
          FullSynapse.
private  org.joone.engine.FullSynapse t2
          Full Synapse.
private  org.joone.engine.learning.TeachingSynapse trainer
          Used to train the neural network.
 
Constructor Summary
NumberNeuralNetworkTrainer(NumberImageFeatureFactory featureFactory, NeuralNetworkParameter neuralNetworkParameter)
          Creates a new instance of NumberNeuralNetworkTrainer with specified feature factory and feature parameter.
 
Method Summary
 void cicleTerminated(org.joone.engine.NeuralNetEvent e)
          Please refer to JOONE doc.
 void errorChanged(org.joone.engine.NeuralNetEvent e)
          Please refer to JOONE doc.
 int GenerateTraingDataFile(NumberCategory[] numberCategory, java.lang.String trainingDataFileName)
          Generate the training data file.
 int getHiddenRows()
          Returns number of hidden neurons.
 void netStarted(org.joone.engine.NeuralNetEvent e)
          Please refer to JOONE doc.
 void netStopped(org.joone.engine.NeuralNetEvent e)
          Please refer to JOONE doc.
 void netStoppedError(org.joone.engine.NeuralNetEvent e, java.lang.String error)
          Please refer to JOONE doc.
 boolean saveNeuralNetwork(java.lang.String fileName)
          Save the neural network.
 void train(NumberCategory[] numberCategory, java.lang.String errorOutputFile, int totCicles)
          Train the neural network.
 void train(java.lang.String inputFile, java.lang.String errorOutputFile, int numOfInputRow, int numOfPattern, int totCicles)
          Train the neural network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

private org.joone.engine.SigmoidLayer input
The input layer of neurons.


hidden

private org.joone.engine.SigmoidLayer hidden
The hidden layer of neurons.


output

private org.joone.engine.SigmoidLayer output
The output layer of neurons.


trainer

private org.joone.engine.learning.TeachingSynapse trainer
Used to train the neural network.


t1

private org.joone.engine.FullSynapse t1
FullSynapse.


t2

private org.joone.engine.FullSynapse t2
Full Synapse.


monitor

private org.joone.engine.Monitor monitor
Monitor.


featureFactory

private NumberImageFeatureFactory featureFactory
Feature factory for this neural network.

Constructor Detail

NumberNeuralNetworkTrainer

public NumberNeuralNetworkTrainer(NumberImageFeatureFactory featureFactory,
                                  NeuralNetworkParameter neuralNetworkParameter)
Creates a new instance of NumberNeuralNetworkTrainer with specified feature factory and feature parameter.

Parameters:
featureFactory - Feature factory.
neuralNetworkParameter - Neural network parameter.
Method Detail

train

public void train(NumberCategory[] numberCategory,
                  java.lang.String errorOutputFile,
                  int totCicles)
Train the neural network.

Parameters:
numberCategory - Array of number category.
errorOutputFile - File to be written to for the error rate information during training.
totCicles - Total iterations during training.

GenerateTraingDataFile

public int GenerateTraingDataFile(NumberCategory[] numberCategory,
                                  java.lang.String trainingDataFileName)
Generate the training data file.

Parameters:
numberCategory - Array of number category.
trainingDataFileName - File name of the training file to be generated.
Returns:
true if the training file can be generated successfully.

train

public void train(java.lang.String inputFile,
                  java.lang.String errorOutputFile,
                  int numOfInputRow,
                  int numOfPattern,
                  int totCicles)
Train the neural network.

Parameters:
inputFile - Training data file name.
errorOutputFile - File to be written to for the error rate information during training.
numOfInputRow - Size per training pattern. This will determine the size of input neurons.
numOfPattern - Number of patterns. This is the number of lines of the training data file.
totCicles - Total iterations during training.

netStopped

public void netStopped(org.joone.engine.NeuralNetEvent e)
Please refer to JOONE doc.

Specified by:
netStopped in interface org.joone.engine.NeuralNetListener
Parameters:
e - Please refer to JOONE doc.

cicleTerminated

public void cicleTerminated(org.joone.engine.NeuralNetEvent e)
Please refer to JOONE doc.

Specified by:
cicleTerminated in interface org.joone.engine.NeuralNetListener
Parameters:
e - Please refer to JOONE doc.

netStarted

public void netStarted(org.joone.engine.NeuralNetEvent e)
Please refer to JOONE doc.

Specified by:
netStarted in interface org.joone.engine.NeuralNetListener
Parameters:
e - Please refer to JOONE doc.

errorChanged

public void errorChanged(org.joone.engine.NeuralNetEvent e)
Please refer to JOONE doc.

Specified by:
errorChanged in interface org.joone.engine.NeuralNetListener
Parameters:
e - Please refer to JOONE doc.

netStoppedError

public void netStoppedError(org.joone.engine.NeuralNetEvent e,
                            java.lang.String error)
Please refer to JOONE doc.

Specified by:
netStoppedError in interface org.joone.engine.NeuralNetListener
Parameters:
e - Please refer to JOONE documentation.
error - Please refer to JOONE documentation.

saveNeuralNetwork

public boolean saveNeuralNetwork(java.lang.String fileName)
Save the neural network.

Parameters:
fileName - File name to be saved into.
Returns:
Whether the neural network can be saved successfully.

getHiddenRows

public int getHiddenRows()
Returns number of hidden neurons.

Returns:
Number of hidden neurons.