Class QNTrainer
java.lang.Object
opennlp.tools.ml.AbstractTrainer
opennlp.tools.ml.AbstractEventTrainer
opennlp.tools.ml.maxent.quasinewton.QNTrainer
- All Implemented Interfaces:
Trainer
,EventTrainer
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default L1-cost value is0.1d
.static final String
static final double
The default L2-cost value is0.1d
.static final String
static final int
The default number of Hessian updates to store is15
.static final String
static final int
The default maximum number of function evaluations is30,000
.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
ConstructorDescriptionInitializes aQNTrainer
.QNTrainer
(int m) Initializes aQNTrainer
with the specified parameterm
.QNTrainer
(int m, int maxFctEval) Initializes aQNTrainer
with the specified parameters.QNTrainer
(TrainingParameters parameters) Initializes aQNTrainer
with the specifiedparameters
. -
Method Summary
Modifier and TypeMethodDescriptiondoTrain
(DataIndexer indexer) void
init
(TrainingParameters trainingParameters, Map<String, String> reportMap) boolean
trainModel
(int iterations, DataIndexer indexer) Trains amodel
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_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
Initializes aQNTrainer
with the specifiedparameters
.- Parameters:
parameters
- TheTrainingParameters
to use.
-
QNTrainer
public QNTrainer(int m) Initializes aQNTrainer
with the specified parameterm
.- Parameters:
m
- The number of hessian updates to store.
-
QNTrainer
public QNTrainer(int m, int maxFctEval) Initializes aQNTrainer
with the specified parameters.- 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 amodel
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.
-