public class EpochTrainer extends Object implements Trainer, Serializable
EpochTrainer is a meta-trainer that combines two trainers. The first or Stage I
trainer is used on a series of randomly selected subsets of the training
patterns. For each subset, the weights are initialized to their initial
values plus a random offset.
The best result from
Stage I training is used as the initial guess for the second or Stage II trainer.
The Stage II trainer uses the full set of training patterns. In EpochTrainer the second trainer
is optional. If the Stage II trainer is null then the best result from
Stage I is returned.
| Constructor and Description |
|---|
EpochTrainer(Trainer stage1Trainer)
Creates a single stage
EpochTrainer. |
EpochTrainer(Trainer stage1Trainer,
Trainer stage2Trainer)
Creates a two-stage
EpochTrainer. |
| Modifier and Type | Method and Description |
|---|---|
int |
getEpochSize()
Returns the number of sample training patterns in each stage 1 epoch.
|
double[] |
getErrorGradient()
Returns the value of the gradient of the error function with
respect to the weights.
|
int |
getErrorStatus()
Returns the training error status.
|
double |
getErrorValue()
Returns the value of the error function.
|
int |
getNumberOfEpochs()
Returns the number of epochs used during stage I training.
|
int |
getNumberOfThreads()
Gets the number of
java.lang.Thread instances to use during
stage I training. |
Random |
getRandom()
Returns the random number generator used to perturb the stage 1 guesses.
|
protected com.imsl.datamining.neural.RandomSampleIndices |
getRandomSampleIndicies()
Gets the random number generators used to select random training
patterns in stage 1.
|
protected Trainer |
getStage1Trainer()
Returns the stage 1 trainer.
|
protected Trainer |
getStage2Trainer()
Returns the stage 1 trainer.
|
protected int |
incrementEpochCount()
Increments the epoch counter.
|
void |
setEpochSize(int epochSize)
Sets the number of randomly selected training patterns in stage 1 epoch.
|
void |
setNumberOfEpochs(int numberOfEpochs)
Sets the number of epochs.
|
void |
setNumberOfThreads(int numberOfThreads)
Sets the number of
java.lang.Thread instances to be used for
parallel processing. |
void |
setRandom(Random random)
Sets the random number generator used to perturb the initial stage 1
guesses.
|
void |
setRandomSamples(Random randomA,
Random randomB)
Sets the random number generators used to select random training
patterns in stage 1.
|
void |
train(Network network,
double[][] xData,
double[][] yData)
Trains the neural network using supplied training patterns.
|
public EpochTrainer(Trainer stage1Trainer)
EpochTrainer. Stage 2 training is
bypassed.stage1Trainer - The Trainer used in stage I.protected int incrementEpochCount()
protected com.imsl.datamining.neural.RandomSampleIndices getRandomSampleIndicies()
RandomSampleIndicies containing the random
number generators.protected Trainer getStage1Trainer()
Trainer containing the stage 1 trainer.protected Trainer getStage2Trainer()
Trainer containing the stage 2 trainer.public void setNumberOfThreads(int numberOfThreads)
java.lang.Thread instances to be used for
parallel processing.numberOfThreads - an int specifying the number of
java.lang.Thread instances to be used for parallel
processing.
Default: numberOfThreads = 1.
public int getNumberOfThreads()
java.lang.Thread instances to use during
stage I training.int which contains the number of
java.lang.Thread instances to use.public void train(Network network, double[][] xData, double[][] yData)
train in interface Trainernetwork - The Network to be trained.xData - A double matrix specifying the input
training patterns. The number of columns in xData
must equal the number of Nodes in
the InputLayer.yData - A double containing the output training
patterns. The number of columns in yData
must equal the number of Perceptrons in the
OutputLayer.
Each row of xData and yData
contains a training pattern. These number of rows in two
arrays must be equal.
public double getErrorValue()
getErrorValue in interface Trainerdouble containing final value of the error
function from the last training. Before training, NaN
is returned.public int getErrorStatus()
getErrorStatus in interface Trainerint containing the error status from stage 2. If
there is no stage 2 then the number of stage 1 epochs that
returned a non-zero error status is returned.public double[] getErrorGradient()
getErrorGradient in interface Trainerdouble array whose length is equal to the number
of Network weights, containing the value of
the gradient of the error function with respect to the
weights. Before training, null is returned.public Random getRandom()
Random object used to generate stage 1
perturbations.public void setRandom(Random random)
random - The Random object used to set the random
number generator.public void setRandomSamples(Random randomA, Random randomB)
randomA - A Random object which is the first random
number generator.randomB - A Random object which is the second random
number generator, independent of randomA.public int getNumberOfEpochs()
int which contains the number of epochs used
during stage I training.public void setNumberOfEpochs(int numberOfEpochs)
numberOfEpochs - An int which specifies the number
of epochs to be used during stage I training.
The default value is 10.public int getEpochSize()
int which contains the number of sample training
patterns in each stage I epoch.public void setEpochSize(int epochSize)
epochSize - An int which specifies the number of
sample training patterns in each stage I epoch.
The default value is the number of observations in the
training data.Copyright © 2020 Rogue Wave Software. All rights reserved.