Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.classifiers.differentiableSequenceScoreBased
Class DiffSSBasedOptimizableFunction

    java.lang.Object
      de.jstacs.algorithms.optimization.DifferentiableFunction
          de.jstacs.classifiers.differentiableSequenceScoreBased.OptimizableFunction
              de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractOptimizableFunction
                  de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractMultiThreadedOptimizableFunction
                      de.jstacs.classifiers.differentiableSequenceScoreBased.DiffSSBasedOptimizableFunction

All Implemented Interfaces:
  Function

Direct Known Subclasses:
  LogGenDisMixFunction

    public abstract class DiffSSBasedOptimizableFunction

extends AbstractMultiThreadedOptimizableFunction

This abstract class is the basis of all multi-threaded `OptimizableFunction`s that are based on `DifferentiableSequenceScore`s.

Author:
  Jens Keilwagen

Nested Class Summary

Nested classes/interfaces inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.OptimizableFunction
`OptimizableFunction.KindOfParameter`

Field Summary
`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.

Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractMultiThreadedOptimizableFunction
`params`

Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractOptimizableFunction
`cl, clazz, data, freeParams, logClazz, norm, sum, weights`

Constructor Summary
`DiffSSBasedOptimizableFunction(int threads, DifferentiableSequenceScore[] score, DataSet[] data, double[][] weights, LogPrior prior, boolean norm, boolean freeParams)` Creates an instance with the underlying infrastructure.

Method Summary
`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.

Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractMultiThreadedOptimizableFunction
`evaluateFunction, evaluateFunction, evaluateGradientOfFunction, evaluateGradientOfFunction, getNumberOfAvailableProcessors, getNumberOfThreads, joinFunction, joinGradients, setDataAndWeights, setParams, stopThreads`

Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.AbstractOptimizableFunction
`getData, getParameters, getSequenceWeights`

Methods inherited from class de.jstacs.algorithms.optimization.DifferentiableFunction
`findOneDimensionalMin`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### shortcut

    protected int[] shortcut

  These shortcuts indicate the beginning of a new part in the parameter vector. Has to be set by `reset()`.

### score

    protected DifferentiableSequenceScore[][] score

  These `DifferentiableSequenceScore`s are used during the parallel computation. `score[t]` contains all `DifferentiableSequenceScore`s that are used by thread `t`.

### dList

    protected DoubleList[][] dList

  These `DoubleList`s are used during the parallel computation of the gradient. `dList[t]` contains all `DoubleList`s that are used by thread `t`.

### iList

    protected IntList[][] iList

  These `IntList`s are used during the parallel computation of the gradient. `iList[t]` contains all `IntList`s that are used by thread `t`.

### prior

    protected LogPrior prior

  The prior that is used in this function.

Constructor Detail

### DiffSSBasedOptimizableFunction

    public DiffSSBasedOptimizableFunction(int threads,
                                          DifferentiableSequenceScore[] score,
                                          DataSet[] data,
                                          double[][] weights,
                                          LogPrior prior,
                                          boolean norm,
                                          boolean freeParams)
                                   throws IllegalArgumentException

  Creates an instance with the underlying infrastructure. Before using this instance, one has to invoke `reset()`.

  Parameters:
    `threads` - the number of threads used for evaluating the function and determining the gradient of the function
    `score` - an array containing the `DifferentiableSequenceScore`s that are used for determining the sequences scores
    `data` - the array of `DataSet`s containing the data that is needed to evaluate the function
    `weights` - the weights for each `Sequence` in each `DataSet` of `data`
    `prior` - the prior that is used for learning the parameters
    `norm` - the switch for using the normalization (division by the number of sequences)
    `freeParams` - the switch for using only the free parameters
  Throws:
    `IllegalArgumentException` - if the number of threads is not positive, the number of classes or the dimension of the weights is not correct

Method Detail

### getClassParams

    public final double[] getClassParams(double[] params)

  Returns from the complete vector of parameters those that are for the classes.

  Parameters:
    `params` - the current parameters
  Returns:
    the parameters for the classes

### getDimensionOfScope

    public final int getDimensionOfScope()

  Description copied from interface: `Function`
  Returns the dimension of the scope of the `Function`.

  Returns:
    the dimension of the scope: `n` with

### setThreadIndependentParameters

    protected void setThreadIndependentParameters()
                                           throws DimensionException

  Description copied from class: `AbstractMultiThreadedOptimizableFunction`
  This method allows to set thread independent parameters. It also allows to check some constraints as for instance the dimension of the parameters.

  Specified by:
    `setThreadIndependentParameters` in class `AbstractMultiThreadedOptimizableFunction`
  Throws:
    `DimensionException` - if the dimension of the parameters is wrong
  See Also:
    `AbstractMultiThreadedOptimizableFunction.setParams(double[])`

### getParameters

    public void getParameters(OptimizableFunction.KindOfParameter kind,
                              double[] erg)
                       throws Exception

  Description copied from class: `AbstractOptimizableFunction`
  This method enables the user to get the parameters without creating a new array.

  Specified by:
    `getParameters` in class `AbstractOptimizableFunction`
  Parameters:
    `kind` - the kind of the class parameters to be returned in `erg`
    `erg` - the array for the start parameters
  Throws:
    `Exception` - if the array is `null` or does not have the correct length
  See Also:
    `OptimizableFunction.getParameters(KindOfParameter)`

### setParams

    protected void setParams(int index)
                      throws DimensionException

  Description copied from class: `AbstractMultiThreadedOptimizableFunction`
  This method sets the parameters for thread `index`

  Specified by:
    `setParams` in class `AbstractMultiThreadedOptimizableFunction`
  Parameters:
    `index` - the index of the thread
  Throws:
    `DimensionException` - if the parameters could not be set
  See Also:
    `AbstractMultiThreadedOptimizableFunction.params`

### addTermToClassParameter

    public final void addTermToClassParameter(int classIndex,
                                              double term)

  This method adds the `term` to the class parameter of the class with index `classIndex`.

  Parameters:
    `classIndex` - the index of the class
    `term` - the term to be added to the class parameter

### reset

    public abstract void reset(DifferentiableSequenceScore[] funs)
                        throws Exception

  This method allows to reset the internally used functions and the corresponding objects.

  Parameters:
    `funs` - the new instances
  Throws:
    `Exception` - if something went wrong

### reset

    public final void reset()
                     throws Exception

  Description copied from class: `OptimizableFunction`
  Resets the all objects and pre-computed values.

  Specified by:
    `reset` in class `OptimizableFunction`
  Throws:
    `Exception` - if something went wrong

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD