Class QNTrainer
java.lang.Object
opennlp.tools.ml.AbstractTrainer
opennlp.tools.ml.AbstractEventTrainer
opennlp.tools.ml.maxent.quasinewton.QNTrainer
- All Implemented Interfaces:
Trainer
,EventTrainer
A Maxent model
Trainer
using L-BFGS algorithm.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
static final String
static final double
static final String
static final int
static final String
static final int
static final String
static final String
static final int
static final String
Fields 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_VALUE
Fields inherited from interface opennlp.tools.ml.EventTrainer
EVENT_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondoTrain
(DataIndexer indexer) void
init
(TrainingParameters trainingParameters, Map<String, String> reportMap) boolean
trainModel
(int iterations, DataIndexer indexer) Trains a model using the QN algorithm.void
validate()
Checks the configuredparameters
.Methods inherited from class opennlp.tools.ml.AbstractEventTrainer
getDataIndexer, train, train
Methods inherited from class opennlp.tools.ml.AbstractTrainer
getAlgorithm, getCutoff, getIterations
-
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_DEFAULT- See Also:
-
L2COST_PARAM
- See Also:
-
L2COST_DEFAULT
public static final double L2COST_DEFAULT- See Also:
-
M_PARAM
- See Also:
-
M_DEFAULT
public static final int M_DEFAULT- See Also:
-
MAX_FCT_EVAL_PARAM
- See Also:
-
MAX_FCT_EVAL_DEFAULT
public static final int MAX_FCT_EVAL_DEFAULT- See Also:
-
-
Constructor Details
-
QNTrainer
public QNTrainer()Initializes aQNTrainer
.Note:
The resulting instance does not print progress messages about training to STDOUT. -
QNTrainer
Initializes aQNTrainer
.- Parameters:
parameters
- TheTrainingParameters
to use.
-
QNTrainer
public QNTrainer(int m) Initializes aQNTrainer
.- Parameters:
m
- The number of hessian updates to store.
-
QNTrainer
public QNTrainer(int m, int maxFctEval) Initializes aQNTrainer
.- Parameters:
m
- The number of hessian updates to store.
-
-
Method Details
-
init
Description copied from class:AbstractTrainer
- Specified by:
init
in interfaceTrainer
- Overrides:
init
in classAbstractTrainer
- Parameters:
trainingParameters
- TheTrainingParameters
to use.reportMap
- TheMap
instance used as report map.
-
validate
public void validate()Description copied from class:AbstractTrainer
Checks the configuredparameters
. If a subclass overrides this, it should callsuper.validate();
.- Overrides:
validate
in classAbstractEventTrainer
-
isSortAndMerge
public boolean isSortAndMerge()- Specified by:
isSortAndMerge
in classAbstractEventTrainer
-
doTrain
- Specified by:
doTrain
in classAbstractEventTrainer
- Throws:
IOException
-
trainModel
Trains a model using the QN algorithm.- Parameters:
iterations
- The number of QN iterations to perform.indexer
- TheDataIndexer
used to compress events in memory.- Returns:
- A trained
QNModel
which can be used immediately or saved to disk using anQNModelWriter
. - Throws:
IllegalArgumentException
- Thrown if parameters were invalid.
-