Class QNTrainer
java.lang.Object
opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.maxent.quasinewton.QNTrainer
- All Implemented Interfaces:
opennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>, opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters>
public class QNTrainer
extends opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
A Maxent model
trainer using the
L-BFGS algorithm.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default L1-cost value is0.1d.static final Stringstatic final doubleThe default L2-cost value is0.1d.static final Stringstatic final intThe default number of Hessian updates to store is15.static final Stringstatic final intThe default maximum number of function evaluations is30,000.static final Stringstatic final Stringstatic final intstatic final StringFields inherited from class opennlp.tools.ml.AbstractEventTrainer
DATA_INDEXER_ONE_PASS_REAL_VALUE, DATA_INDEXER_ONE_PASS_VALUE, DATA_INDEXER_PARAM, DATA_INDEXER_TWO_PASS_VALUEFields inherited from interface opennlp.tools.ml.EventTrainer
EVENT_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionInitializes aQNTrainer.QNTrainer(int m) Initializes aQNTrainerwith the specified parameterm.QNTrainer(int m, int maxFctEval) Initializes aQNTrainerwith the specified parameters.QNTrainer(opennlp.tools.util.TrainingParameters parameters) Initializes aQNTrainerwith the specifiedparameters. -
Method Summary
Modifier and TypeMethodDescriptionopennlp.tools.ml.model.AbstractModeldoTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) voidbooleantrainModel(int iterations, opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) Trains amodelusing the QN algorithm.voidvalidate()Methods inherited from class opennlp.tools.ml.AbstractEventTrainer
getDataIndexer, train, trainMethods inherited from class opennlp.tools.ml.AbstractTrainer
getAlgorithm, getCutoff, getIterations, getTrainingConfiguration, initMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.commons.Trainer
init
-
Field Details
-
MAXENT_QN_VALUE
- See Also:
-
THREADS_PARAM
- See Also:
-
THREADS_DEFAULT
public static final int THREADS_DEFAULT- See Also:
-
L1COST_PARAM
- See Also:
-
L1COST_DEFAULT
public static final double L1COST_DEFAULTThe default L1-cost value is0.1d.- See Also:
-
L2COST_PARAM
- See Also:
-
L2COST_DEFAULT
public static final double L2COST_DEFAULTThe default L2-cost value is0.1d.- See Also:
-
M_PARAM
- See Also:
-
M_DEFAULT
public static final int M_DEFAULTThe default number of Hessian updates to store is15.- See Also:
-
MAX_FCT_EVAL_PARAM
- See Also:
-
MAX_FCT_EVAL_DEFAULT
public static final int MAX_FCT_EVAL_DEFAULTThe default maximum number of function evaluations is30,000.- See Also:
-
-
Constructor Details
-
QNTrainer
public QNTrainer()Initializes aQNTrainer. -
QNTrainer
public QNTrainer(opennlp.tools.util.TrainingParameters parameters) Initializes aQNTrainerwith the specifiedparameters.- Parameters:
parameters- TheTrainingParametersto use.
-
QNTrainer
public QNTrainer(int m) Initializes aQNTrainerwith the specified parameterm.- Parameters:
m- The number of hessian updates to store.
-
QNTrainer
public QNTrainer(int m, int maxFctEval) Initializes aQNTrainerwith the specified parameters.- Parameters:
m- The number of hessian updates to store.
-
-
Method Details
-
init
public void init(opennlp.tools.util.TrainingParameters trainingParameters, Map<String, String> reportMap) - Specified by:
initin interfaceopennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>- Overrides:
initin classopennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
-
validate
public void validate()- Overrides:
validatein classopennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
-
isSortAndMerge
public boolean isSortAndMerge()- Specified by:
isSortAndMergein classopennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
-
doTrain
public opennlp.tools.ml.model.AbstractModel doTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) throws IOException - Specified by:
doTrainin classopennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>- Throws:
IOException
-
trainModel
public QNModel trainModel(int iterations, opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) Trains amodelusing the QN algorithm.- Parameters:
iterations- The number of QN iterations to perform.indexer- TheDataIndexerused to compress events in memory.- Returns:
- A trained
QNModelwhich can be used immediately or saved to disk using anQNModelWriter. - Throws:
IllegalArgumentException- Thrown if parameters were invalid.
-