org.encog.ml.ea.train.basic
Class TrainEA
- java.lang.Object
-
- org.encog.ml.ea.train.basic.BasicEA
-
- org.encog.ml.ea.train.basic.TrainEA
-
- All Implemented Interfaces:
- java.io.Serializable, EncogShutdownTask, EvolutionaryAlgorithm, MLTrain, MultiThreadable
- Direct Known Subclasses:
- MLMethodGeneticAlgorithm.MLMethodGeneticAlgorithmHelper
public class TrainEA extends BasicEA implements MLTrain
Provides a MLTrain compatible class that can be used to train genomes.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description TrainEA(Population thePopulation, CalculateScore theScoreFunction)Create a trainer for a score function.TrainEA(Population thePopulation, MLDataSet trainingData)Create a trainer for training data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddStrategy(Strategy strategy)Training strategies can be added to improve the training results.booleancanContinue()voidfinishTraining()Called when training is finished.TrainingImplementationTypegetImplementationType()MLMethodgetMethod()Get the current best machine learning method from the training.java.util.List<Strategy>getStrategies()MLDataSetgetTraining()Returns null, does not use a training set, rather uses a score function.booleanisTrainingDone()voiditeration()Perform a training iteration.voiditeration(int count)Perform the specified number of training iterations.TrainingContinuationpause()Pause the training to continue later.voidpostIteration()Call the strategies after an iteration.voidpreIteration()Call the strategies before an iteration.voidresume(TrainingContinuation state)Resume training.voidsetError(double error)Not used.-
Methods inherited from class org.encog.ml.ea.train.basic.BasicEA
addChild, addOperation, addScoreAdjuster, calculateScore, calculateScoreAdjustment, getBestComparator, getBestGenome, getChampMutation, getCODEC, getEliteRate, getError, getIteration, getMaxIndividualSize, getMaxOperationErrors, getMaxTries, getOldBestGenome, getOperators, getPopulation, getRandomNumberFactory, getScoreAdjusters, getScoreFunction, getSelection, getSelectionComparator, getShouldIgnoreExceptions, getSpeciation, getThreadCount, isValidationMode, performShutdownTask, reportError, setBestComparator, setChampMutation, setCODEC, setEliteRate, setIteration, setMaxOperationErrors, setMaxTries, setPopulation, setRandomNumberFactory, setSelection, setSelectionComparator, setShouldIgnoreExceptions, setSpeciation, setThreadCount, setValidationMode
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.encog.ml.train.MLTrain
getError, getIteration, setIteration
-
-
-
-
Constructor Detail
-
TrainEA
public TrainEA(Population thePopulation, CalculateScore theScoreFunction)
Create a trainer for a score function.- Parameters:
thePopulation- The population.theScoreFunction- The score function.
-
TrainEA
public TrainEA(Population thePopulation, MLDataSet trainingData)
Create a trainer for training data.- Parameters:
thePopulation- The population.trainingData- The training data.
-
-
Method Detail
-
setError
public void setError(double error)
Not used.
-
isTrainingDone
public boolean isTrainingDone()
- Specified by:
isTrainingDonein interfaceMLTrain- Returns:
- True if training can progress no further.
-
getImplementationType
public TrainingImplementationType getImplementationType()
- Specified by:
getImplementationTypein interfaceMLTrain- Returns:
- The training implementation type.
-
iteration
public void iteration(int count)
Perform the specified number of training iterations. This is a basic implementation that just calls iteration the specified number of times. However, some training methods, particularly with the GPU, benefit greatly by calling with higher numbers than 1.
-
pause
public TrainingContinuation pause()
Pause the training to continue later.
-
resume
public void resume(TrainingContinuation state)
Resume training.
-
addStrategy
public void addStrategy(Strategy strategy)
Training strategies can be added to improve the training results. There are a number to choose from, and several can be used at once.- Specified by:
addStrategyin interfaceMLTrain- Parameters:
strategy- The strategy to add.
-
canContinue
public boolean canContinue()
- Specified by:
canContinuein interfaceMLTrain- Returns:
- True if the training can be paused, and later continued.
-
finishTraining
public void finishTraining()
Called when training is finished. This allows the EA to properly shut down.- Specified by:
finishTrainingin interfaceEvolutionaryAlgorithm- Specified by:
finishTrainingin interfaceMLTrain- Overrides:
finishTrainingin classBasicEA
-
getMethod
public MLMethod getMethod()
Description copied from interface:MLTrainGet the current best machine learning method from the training.
-
getTraining
public MLDataSet getTraining()
Returns null, does not use a training set, rather uses a score function.- Specified by:
getTrainingin interfaceMLTrain- Returns:
- null, not used.
-
getStrategies
public java.util.List<Strategy> getStrategies()
- Specified by:
getStrategiesin interfaceMLTrain- Returns:
- The strategies to use.
-
iteration
public void iteration()
Description copied from class:BasicEAPerform a training iteration. Also called generations or epochs.
-
postIteration
public void postIteration()
Call the strategies after an iteration.
-
preIteration
public void preIteration()
Call the strategies before an iteration.
-
-
DMelt 3.0 © DataMelt by jWork.ORG