|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.fst.ThreadedOptimizable
public class ThreadedOptimizable
An adaptor for optimizables based on batch values/gradients.
Computes values, gradients for each batch in multiple threads and combines them in the end.
CRFOptimizableByBatchLabelLikelihood
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface cc.mallet.optimize.Optimizable |
---|
Optimizable.ByBatchGradient, Optimizable.ByCombiningBatchGradient, Optimizable.ByGISUpdate, Optimizable.ByGradient, Optimizable.ByGradientValue, Optimizable.ByHessian, Optimizable.ByValue, Optimizable.ByVotedPerceptron |
Field Summary | |
---|---|
protected java.util.List<double[]> |
batchCachedGradient
Gradient obtained from the optimizable for each batch |
protected double[] |
batchCachedValue
Value obtained from the optimizable for each batch |
protected CacheStaleIndicator |
cacheIndicator
|
protected Optimizable.ByCombiningBatchGradient |
optimizable
optimizable to be parallelized |
static int |
SLEEP_TIME
|
protected InstanceList |
trainingSet
Data |
Constructor Summary | |
---|---|
ThreadedOptimizable(Optimizable.ByCombiningBatchGradient optimizable,
InstanceList trainingSet,
int numFactors,
CacheStaleIndicator cacheIndicator)
Initializes the optimizable and starts new threads. |
Method Summary | |
---|---|
protected void |
createTasks()
Creates tasks to be executed in parallel, each task looks at a batch of data. |
int |
getNumParameters()
|
Optimizable.ByCombiningBatchGradient |
getOptimizable()
|
double |
getParameter(int index)
|
void |
getParameters(double[] buffer)
|
double |
getValue()
|
void |
getValueGradient(double[] buffer)
Returns the gradient, re-computes if gradient is stale. |
void |
setParameter(int index,
double value)
|
void |
setParameters(double[] buff)
|
void |
shutdown()
Shuts down the executor used to start and run threads to compute values and gradients. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected InstanceList trainingSet
protected Optimizable.ByCombiningBatchGradient optimizable
protected double[] batchCachedValue
protected java.util.List<double[]> batchCachedGradient
protected CacheStaleIndicator cacheIndicator
public static final int SLEEP_TIME
Constructor Detail |
---|
public ThreadedOptimizable(Optimizable.ByCombiningBatchGradient optimizable, InstanceList trainingSet, int numFactors, CacheStaleIndicator cacheIndicator)
optimizable
- Optimizable to be parallelizednumFactors
- Number of factors in model's parameters, used to
initialize the gradientcacheIndicator
- Determines when value/gradient become staleMethod Detail |
---|
public Optimizable.ByCombiningBatchGradient getOptimizable()
public void shutdown()
*Note*: For a clean exit of all the threads, it is recommended to call this method after training finishes.
public double getValue()
getValue
in interface Optimizable.ByGradientValue
public void getValueGradient(double[] buffer)
*Note*: Assumes that buffer is already initialized.
getValueGradient
in interface Optimizable.ByGradientValue
protected void createTasks()
public int getNumParameters()
getNumParameters
in interface Optimizable
public void getParameters(double[] buffer)
getParameters
in interface Optimizable
public double getParameter(int index)
getParameter
in interface Optimizable
public void setParameters(double[] buff)
setParameters
in interface Optimizable
public void setParameter(int index, double value)
setParameter
in interface Optimizable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |