|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sjain.neurun.NeuralNetwork
This class contains the logic for training and running a multilayer neural network using the backpropagation algorithm. You can create a NeuralNetwork specified in a file given to the constructor as an argument, and call a method that will train the neural network. The trained NeuralNetwork can then be run to get the output results for new input data. The NeuralNetwork can have as many layers as you want.
The constructor accepts the name of a file with the training data, or the trained
network, and an argument that says whether that file has training data or a trained
network. The format of the file is given in the documentation for the class
TrainingData
.
The mathematical operations use the Matrix class in the Jama package for Matrix mathematics, from the National Institute of Standards and Technology, and MathWorks. To understand the source code, it is worth reading the documentation for this class first.
Inner Class Summary | |
class |
NeuralNetwork.NeuralNetworkException
Captures the exceptions thrown by the NeuralNetwork and its nested classes |
class |
NeuralNetwork.TrainingData
Reads training data or the parameters of a trained network from a file |
Field Summary | |
static int |
TO_TRAIN
Specifies that a neural network needs to be trained |
static int |
TRAINED
Specifies that a trained neural network is being loaded |
Constructor Summary | |
NeuralNetwork(java.lang.String networkFilename,
int type)
Constructs a neural network based on the data in the file, networkFilename. |
Method Summary | |
int |
numberOfInputNeurons()
Returns the number of neurons in the input layer. |
int |
numberOfLayers()
Returns the number of layers in the neural network. |
int |
numberOfOutputNeurons()
Returns the number of neurons in the output layer. |
void |
printNeuralNetwork()
Prints all the weight and parameter values. |
double[] |
runNetwork(double[] input)
Returns the output values, given the input values. |
void |
trainNetwork(java.lang.String networkOutputFilename,
int showStatusFrequency)
Trains the neural network to recognize patterns. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TO_TRAIN
public static final int TRAINED
Constructor Detail |
public NeuralNetwork(java.lang.String networkFilename, int type)
networkFilename
- A file with the network structure and training data or trained network.type
- If type = TO_TRAIN, the file has training data, if type = TRAINED it has a trained network.Method Detail |
public void trainNetwork(java.lang.String networkOutputFilename, int showStatusFrequency)
networkOutputFilename
- Name of the file to which to write the trained network.showStatusFrequency
- Number of training cycles after which the network should show its results.public double[] runNetwork(double[] input)
input
- Values to be fed into the input neurons of the network. Length of array must equal number of input neurons.public int numberOfLayers()
public int numberOfInputNeurons()
public int numberOfOutputNeurons()
public void printNeuralNetwork()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |