public abstract class DiffSSBasedOptimizableFunction extends AbstractMultiThreadedOptimizableFunction
OptimizableFunction
s that are based on DifferentiableSequenceScore
s.OptimizableFunction.KindOfParameter
Modifier and Type | Field and Description |
---|---|
protected DoubleList[][] |
dList
These
DoubleList s are used during the parallel computation of the gradient. |
protected IntList[][] |
iList
These
IntList s are used during the parallel computation of the gradient. |
protected LogPrior |
prior
The prior that is used in this function.
|
protected DifferentiableSequenceScore[][] |
score
These
DifferentiableSequenceScore s are used during the parallel computation. |
protected int[] |
shortcut
These shortcuts indicate the beginning of a new part in the parameter vector.
|
params, worker
cl, clazz, data, freeParams, logClazz, norm, sum, weights
Constructor and Description |
---|
DiffSSBasedOptimizableFunction(int threads,
DifferentiableSequenceScore[] score,
DataSet[] data,
double[][] weights,
LogPrior prior,
boolean norm,
boolean freeParams)
Creates an instance with the underlying infrastructure.
|
Modifier and Type | Method and Description |
---|---|
void |
addTermToClassParameter(int classIndex,
double term)
This method adds the
term to the class parameter of the
class with index classIndex . |
double[] |
getClassParams(double[] params)
Returns from the complete vector of parameters those that are for the
classes.
|
int |
getDimensionOfScope()
Returns the dimension of the scope of the
Function . |
void |
getParameters(OptimizableFunction.KindOfParameter kind,
double[] erg)
This method enables the user to get the parameters without creating a new
array.
|
void |
reset()
Resets the all objects and pre-computed values.
|
abstract void |
reset(DifferentiableSequenceScore[] funs)
This method allows to reset the internally used functions and the corresponding objects.
|
protected void |
setParams(int index)
This method sets the parameters for thread
index |
protected void |
setThreadIndependentParameters()
This method allows to set thread independent parameters.
|
evaluateFunction, evaluateFunction, evaluateGradientOfFunction, evaluateGradientOfFunction, getNumberOfAvailableProcessors, getNumberOfThreads, joinFunction, joinGradients, prepareThreads, setDataAndWeights, setParams, stopThreads
getData, getParameters, getSequenceWeights
findOneDimensionalMin
protected int[] shortcut
reset()
.protected DifferentiableSequenceScore[][] score
DifferentiableSequenceScore
s are used during the parallel computation.
score[t]
contains all DifferentiableSequenceScore
s that are used by thread t
.protected DoubleList[][] dList
DoubleList
s are used during the parallel computation of the gradient.
dList[t]
contains all DoubleList
s that are used by thread t
.protected IntList[][] iList
protected LogPrior prior
public DiffSSBasedOptimizableFunction(int threads, DifferentiableSequenceScore[] score, DataSet[] data, double[][] weights, LogPrior prior, boolean norm, boolean freeParams) throws IllegalArgumentException
reset()
.threads
- the number of threads used for evaluating the function and determining the gradient of the functionscore
- an array containing the DifferentiableSequenceScore
s that are used for determining the sequences scoresdata
- the array of DataSet
s containing the data that is needed to evaluate the functionweights
- the weights for each Sequence
in each DataSet
of data
prior
- the prior that is used for learning the parametersnorm
- the switch for using the normalization (division by the number
of sequences)freeParams
- the switch for using only the free parametersIllegalArgumentException
- if the number of threads is not positive, the number of classes or the dimension of the weights is not correctpublic final double[] getClassParams(double[] params)
params
- the current parameterspublic final int getDimensionOfScope()
Function
Function
.n
with
protected void setThreadIndependentParameters() throws DimensionException
AbstractMultiThreadedOptimizableFunction
setThreadIndependentParameters
in class AbstractMultiThreadedOptimizableFunction
DimensionException
- if the dimension of the parameters is wrongAbstractMultiThreadedOptimizableFunction.setParams(double[])
public void getParameters(OptimizableFunction.KindOfParameter kind, double[] erg) throws Exception
AbstractOptimizableFunction
getParameters
in class AbstractOptimizableFunction
kind
- the kind of the class parameters to be returned in
erg
erg
- the array for the start parametersException
- if the array is null
or does not have the
correct lengthOptimizableFunction.getParameters(KindOfParameter)
protected void setParams(int index) throws DimensionException
AbstractMultiThreadedOptimizableFunction
index
setParams
in class AbstractMultiThreadedOptimizableFunction
index
- the index of the threadDimensionException
- if the parameters could not be setAbstractMultiThreadedOptimizableFunction.params
public final void addTermToClassParameter(int classIndex, double term)
term
to the class parameter of the
class with index classIndex
.classIndex
- the index of the classterm
- the term to be added to the class parameterpublic abstract void reset(DifferentiableSequenceScore[] funs) throws Exception
funs
- the new instancesException
- if something went wrongpublic final void reset() throws Exception
OptimizableFunction
reset
in class OptimizableFunction
Exception
- if something went wrong