Class ParallelNegLogLikelihood
java.lang.Object
opennlp.tools.ml.maxent.quasinewton.NegLogLikelihood
opennlp.tools.ml.maxent.quasinewton.ParallelNegLogLikelihood
- All Implemented Interfaces:
Function
Evaluates
negative log-likelihood and
its gradient in parallel.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classAParallelNegLogLikelihood.ComputeTaskthat is computed in parallel.(package private) classAParallelNegLogLikelihood.ComputeTaskfor computing partial gradient.(package private) classAParallelNegLogLikelihood.ComputeTaskfor computing partial value of negative log-likelihood. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[][]private static final org.slf4j.Loggerprivate final double[]private final intFields inherited from class NegLogLikelihood
contexts, dimension, expectation, gradient, numContexts, numFeatures, numOutcomes, numTimesEventsSeen, outcomeList, tempSums, values -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcomputeInParallel(double[] x, Class<? extends ParallelNegLogLikelihood.ComputeTask> taskClass) Computes the specified tasks in parallel.double[]gradientAt(double[] x) Computes the gradient forx.doublevalueAt(double[] x) Computes the function value forx.Methods inherited from class NegLogLikelihood
getDimension, getInitialPoint, indexOf
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
threads
private final int threads -
negLogLikelihoodThread
private final double[] negLogLikelihoodThread -
gradientThread
private final double[][] gradientThread
-
-
Constructor Details
-
ParallelNegLogLikelihood
- Parameters:
indexer- TheDataIndexerto use as input provider.threads- The number of thread to compute with in parallel. Must be greater than0.- Throws:
IllegalArgumentException- Thrown if parameters were invalid.
-
-
Method Details
-
valueAt
public double valueAt(double[] x) Computes the function value forx.- Specified by:
valueAtin interfaceFunction- Overrides:
valueAtin classNegLogLikelihood- Parameters:
x- The input.- Returns:
- Returns the computed negative log-likelihood.
- Throws:
IllegalArgumentException- Thrown if parameters were invalid.
-
gradientAt
public double[] gradientAt(double[] x) Computes the gradient forx.- Specified by:
gradientAtin interfaceFunction- Overrides:
gradientAtin classNegLogLikelihood- Parameters:
x- The input.- Returns:
- Returns the computed gradient.
- Throws:
IllegalArgumentException- Thrown if parameters were invalid.
-
computeInParallel
private void computeInParallel(double[] x, Class<? extends ParallelNegLogLikelihood.ComputeTask> taskClass) Computes the specified tasks in parallel.
-