Package com.googlecode.fannj
Class Trainer
- java.lang.Object
-
- com.googlecode.fannj.Trainer
-
public class Trainer extends java.lang.Object
Trains an ANN. Currently only File based training is supported.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description float
cascadeTrain(java.lang.String dataFile, int maxNeurons, int neuronsBetweenReports, float desiredError)
protected static void
fann_cascadetrain_on_file(com.sun.jna.Pointer ann, java.lang.String filename, int max_neurons, int neurons_between_reports, float desired_error)
protected static void
fann_destroy_train(com.sun.jna.Pointer data)
Deallocate the dataprotected static float
fann_get_MSE(com.sun.jna.Pointer ann)
Reads the mean square error from the network.protected static int
fann_get_training_algorithm(com.sun.jna.Pointer ann)
protected static com.sun.jna.Pointer
fann_read_train_from_file(java.lang.String filename)
Read the training or testing data from a file You must callfann_destroy_train(Pointer)
on thePointer
you get from this after you have finished with itprotected static void
fann_reset_MSE(com.sun.jna.Pointer ann)
Resets the mean square error from the network.protected static void
fann_set_training_algorithm(com.sun.jna.Pointer ann, int training_algorithm)
protected static float
fann_test_data(com.sun.jna.Pointer ann, com.sun.jna.Pointer data)
Test the network using data and return the MSE of the network.protected static void
fann_train_on_file(com.sun.jna.Pointer ann, java.lang.String filename, int max_epochs, int epochs_between_reports, float desired_error)
void
setTrainingAlgorithm(TrainingAlgorithm algorithm)
float
test(java.lang.String testingFile)
float
train(java.lang.String trainingFile, int maxEpochs, int epochsBetweenReports, float desiredError)
-
-
-
Constructor Detail
-
Trainer
public Trainer(Fann fann)
-
-
Method Detail
-
train
public float train(java.lang.String trainingFile, int maxEpochs, int epochsBetweenReports, float desiredError)
- Parameters:
trainingFile
-maxEpochs
-epochsBetweenReports
-desiredError
-- Returns:
- MSE for the ann once trained
-
cascadeTrain
public float cascadeTrain(java.lang.String dataFile, int maxNeurons, int neuronsBetweenReports, float desiredError)
- Parameters:
dataFile
-maxNeurons
-neuronsBetweenReports
-desiredError
-- Returns:
- MSE for the ann once trained
-
setTrainingAlgorithm
public void setTrainingAlgorithm(TrainingAlgorithm algorithm)
-
test
public float test(java.lang.String testingFile)
- Parameters:
testingFile
-- Returns:
- MSE for the Fann which has been tested
-
fann_train_on_file
protected static void fann_train_on_file(com.sun.jna.Pointer ann, java.lang.String filename, int max_epochs, int epochs_between_reports, float desired_error)
-
fann_cascadetrain_on_file
protected static void fann_cascadetrain_on_file(com.sun.jna.Pointer ann, java.lang.String filename, int max_neurons, int neurons_between_reports, float desired_error)
-
fann_set_training_algorithm
protected static void fann_set_training_algorithm(com.sun.jna.Pointer ann, int training_algorithm)
-
fann_get_training_algorithm
protected static int fann_get_training_algorithm(com.sun.jna.Pointer ann)
-
fann_reset_MSE
protected static void fann_reset_MSE(com.sun.jna.Pointer ann)
Resets the mean square error from the network.- Parameters:
ann
-
-
fann_get_MSE
protected static float fann_get_MSE(com.sun.jna.Pointer ann)
Reads the mean square error from the network.- Parameters:
ann
-- Returns:
- the mean square error of the network
-
fann_test_data
protected static float fann_test_data(com.sun.jna.Pointer ann, com.sun.jna.Pointer data)
Test the network using data and return the MSE of the network. You might need to runfann_reset_MSE(Pointer)
first- Parameters:
ann
-data
- the data to test with- Returns:
- the mean square error of the network
-
fann_read_train_from_file
protected static com.sun.jna.Pointer fann_read_train_from_file(java.lang.String filename)
Read the training or testing data from a file You must callfann_destroy_train(Pointer)
on thePointer
you get from this after you have finished with it- Parameters:
filename
- the file name of the file to read the data from- Returns:
- pointer to the data which has been read for use with
fann_test_data(Pointer,Pointer)
-
fann_destroy_train
protected static void fann_destroy_train(com.sun.jna.Pointer data)
Deallocate the data- Parameters:
data
- the training/testing data to deallocate
-
-