|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.penguinwerks.jodene.Trainer
Trains the network. The trainer configures the neurons in the network for training, with the given training parameters, and runs the training loop.
The trainer is given a set of training examples and uses those
examples in the training loop to train the network. The trainer
continues to present the examples until it is told to terminate,
or the hardMax limit is reached. To configure the
manner in which training is stopped, EpochEventListeners
can be added. At the end of each training epoch, the listeners
are send the endEpoch event. The MaxIterationsListener, for example,
terminates training when a pre-set number of iterations occured.
The trainer is configured by setting the epochSize, the learningRate, and the momentum. If on-line training is used, the epochSize is set to 1, otherwise, it is the size of the trainingExamples, by default. If the appropriate EpochEventListener is implemented, techniques, such as adjusting the learning rate or momentum are possible.
Change on 04/24/04 The error handling has been switched to an error manager and a default error name. Also error history has been refactored to the error manager.
| Constructor Summary | |
Trainer()
Default constructor. |
|
| Method Summary | |
void |
addCalculator(ErrorCalculator calculator)
The error calculator computes the error from the input values and the output values. |
void |
addCalculator(java.lang.String name,
ErrorCalculator calculator)
The error calculator computes the error from the input values and the output values. |
void |
addEpochEventListener(EpochEventListener listener)
Adds an epoch event listener to the list of listeners. |
void |
endEpoch(Network network)
Called at the end of an epoch. |
void |
fireEpochEvent(Network network)
Fires an epoch training event to all the listeners. |
int |
getEpochCount()
Returns the epoch count so far. |
int |
getEpochSize()
The epoch size is the number of examples to present during training before the error is saved and the weights are adjusted. |
ErrorManager |
getErrorManager()
Returns the error manager used by the trainer when calculating training error. |
int |
getHardMax()
If no EpochEventListeners are added to the network the hardMax limit is used to safely stop training. |
double |
getLearningRate()
Returns the default learning rate set for training. |
double |
getMomentum()
Returns the momentum used during training. |
NeuronTraining |
getTraining()
Returns the default neuron training for this trainer. |
ExampleSet |
getTrainingExamples()
The training examples are set of known inputs and their outputs used to train the network. |
void |
requestTermination()
Used primarily by the epoch event listeners to request the neural network to stop training. |
void |
setDefaultErrorName(java.lang.String name)
Sets the default error name to examine. |
void |
setEpochSize(int epochSize)
The epoch size is the number of examples to present during training before the error is saved and the weights are adjusted. |
void |
setHardMax(int hardMax)
If no EpochEventListeners are added to the network the hardMax limit is used to safely stop training. |
void |
setLearningRate(double val)
Set the default learning rate used for training. |
void |
setMomentum(double val)
Sets the momentum used during training. |
void |
setTrainingExamples(ExampleSet trainingExamples)
The training examples are set of known inputs and their outputs used to train the network. |
void |
train(Network network)
Called to train the network. |
void |
updateWeightAdjustments()
Causes the weight adjustments to be updated at all the neuron trainers. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Trainer()
| Method Detail |
public int getHardMax()
public void setHardMax(int hardMax)
hardMax - The hardMax to set.public double getLearningRate()
public void setLearningRate(double val)
val - The new learning rate.public double getMomentum()
public void setMomentum(double val)
val - The new momentum.public void addCalculator(ErrorCalculator calculator)
calculator - The calculator to set.
public void addCalculator(java.lang.String name,
ErrorCalculator calculator)
calculator - The calculator to set.name - The name of the error calculator.public int getEpochSize()
public void setEpochSize(int epochSize)
epochSize - The epochSize to set.public ExampleSet getTrainingExamples()
public void setTrainingExamples(ExampleSet trainingExamples)
trainingExamples - The trainingExamples to set.
public void train(Network network)
throws TrainingException
Called to train the network. Iterates until the terminating flag is set. If there are no training event listeners set then there is a hard termination limit of 10000 (by default) iterations.
The training algorithm is simple. It presents the training examples in order, up to epochSize before ending the epoch. At that point the error for the epoch is calculated and the EndEpochEvent is sent to all the listeners. The weights of the network are then adjusted. Training stops when the hard limit is reached (given no listeners) or by a listener requesting a termination.
network - The network to train.
TrainingException - Thrown if a problem with training occurs.public void updateWeightAdjustments()
public void endEpoch(Network network)
network - The network being trained.public NeuronTraining getTraining()
public void requestTermination()
public void fireEpochEvent(Network network)
network - The network for which the event is fired.public void addEpochEventListener(EpochEventListener listener)
listener - A new listener for epoch events.public int getEpochCount()
public ErrorManager getErrorManager()
public void setDefaultErrorName(java.lang.String name)
name - The default error name to use.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||