|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement
de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.BasicTransitionElement
de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.TransitionElement
public class TransitionElement
This class implements an transition element implements method used for training via sampling or gradient based optimization approach.
Field Summary | |
---|---|
protected int |
offset
The internally used parameter offset. |
protected double[] |
probs
The precomputed probabilities for each possible transition. |
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement |
---|
context, descendants, hyperParameters, logNorm, parameters, states, statistic |
Constructor Summary | |
---|---|
TransitionElement(int[] context,
int[] states,
double[] hyperParameters)
This is the main constructor creating a new instance with given context, descendant states, and hyper parameters. |
|
TransitionElement(int[] context,
int[] states,
double[] hyperParameters,
double[] weight)
This is the main constructor creating a new instance with given context, descendant states, and hyper parameters. |
|
TransitionElement(StringBuffer xml)
The standard constructor for the interface Storable . |
Method Summary | |
---|---|
void |
addGradientForLogPriorTerm(double[] gradient,
int start)
This method computes the gradient of BasicHigherOrderTransition.AbstractTransitionElement.getLogPriorTerm() for each
parameter of this transition element. |
TransitionElement |
clone()
|
int |
fillParameters(double[] params,
int offset)
This method fills the current parameters of this TransitionElement into the given array params
starting at position offset . |
double |
getLogPosteriorFromStatistic()
This method computes the log posterior from the internal sufficient statistic. |
double |
getLogScoreAndPartialDerivation(int childIdx,
IntList indices,
DoubleList partialDer,
Sequence sequence,
int sequencePosition)
Returns the logarithmic score and fills lists with the indices and the partial derivations. |
double |
getMinimalHyperparameter()
This method returns the minimal hyper parameters of this TransitionElement . |
protected void |
init()
This method initializes internal fields. |
protected void |
precompute()
This method precomputes internal fields as for instance the normalization constant. |
int |
setParameterOffset(int o)
This method sets the internal offset used for several methods (cf. see tags). |
int |
setParameters(double[] params,
int start)
This method sets the internal parameters to the values of params beginning at index start . |
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.elements.BasicTransitionElement |
---|
appendFurtherInformation, extractFurtherInformation |
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.hmm.transitions.BasicHigherOrderTransition.AbstractTransitionElement |
---|
addToStatistic, appendGraphvizDescription, appendTransitions, drawParametersFromStatistic, estimateFromStatistic, getArrowOption, getChild, getContext, getDescendant, getGraphvizEdgeWeight, getLabel, getLogGammaScoreFromStatistic, getLogPriorTerm, getLogScoreFor, getNextContext, getNumberOfChildren, getNumberOfParameters, getXMLTag, initializeRandomly, joinStatistics, resetStatistic, setIndexOfDescendantTransitionElement, setParameters, toString, toString, toXML |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double[] probs
getLogScoreAndPartialDerivation(int, IntList, DoubleList, Sequence, int)
,
addGradientForLogPriorTerm(double[], int)
protected int offset
setParameterOffset(int)
,
getLogScoreAndPartialDerivation(int, IntList, DoubleList, Sequence, int)
,
addGradientForLogPriorTerm(double[], int)
Constructor Detail |
---|
public TransitionElement(int[] context, int[] states, double[] hyperParameters)
context
- the context (=previously visited state indices); last entry corresponds to the last state visitedstates
- the transitions to all possible states; if null
than no transition allowedhyperParameters
- the hyper parameters for the transitions; if null
than no prior is usedTransitionElement(int[], int[], double[], double[])
public TransitionElement(int[] context, int[] states, double[] hyperParameters, double[] weight)
context
- the context (=previously visited state indices); last entry corresponds to the last state visitedstates
- the transitions to all possible states; if null
than no transition allowedhyperParameters
- the hyper parameters for the transitions; if null
than no prior is usedweight
- the weight for plotting the edge in Graphviz, enables to modify the edge length, larger weights imply shorter edges (default: 1)public TransitionElement(StringBuffer xml) throws NonParsableException
Storable
.
Constructs a TransitionElement
out of an XML representation.
xml
- the XML representation as StringBuffer
NonParsableException
- if the TransitionElement
could not be reconstructed out of
the StringBuffer
xml
Method Detail |
---|
public TransitionElement clone() throws CloneNotSupportedException
clone
in class BasicHigherOrderTransition.AbstractTransitionElement
CloneNotSupportedException
protected void init()
BasicHigherOrderTransition.AbstractTransitionElement
init
in class BasicHigherOrderTransition.AbstractTransitionElement
protected void precompute()
BasicHigherOrderTransition.AbstractTransitionElement
precompute
in class BasicHigherOrderTransition.AbstractTransitionElement
BasicHigherOrderTransition.AbstractTransitionElement.logNorm
public double getLogScoreAndPartialDerivation(int childIdx, IntList indices, DoubleList partialDer, Sequence sequence, int sequencePosition)
childIdx
- the index of the child to be visitedindices
- an IntList
of indices, after method invocation the
list should contain the indices i where
partialDer
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
sequence
- the Sequence
that can be used to extract SequenceAnnotation
sequencePosition
- the position within the sequence
public int setParameterOffset(int o)
offset
used for several methods (cf. see tags).
o
- the offset to be set
TransitionElement
offset
,
getLogScoreAndPartialDerivation(int, IntList, DoubleList, Sequence, int)
,
addGradientForLogPriorTerm(double[], int)
public int fillParameters(double[] params, int offset)
TransitionElement
into the given array params
starting at position offset
.
params
- the array for filling the parametersoffset
- the start index
public int setParameters(double[] params, int start)
params
beginning at index start
.
params
- the new parametersstart
- the start index in params
params
that has not been usedpublic void addGradientForLogPriorTerm(double[] gradient, int start)
BasicHigherOrderTransition.AbstractTransitionElement.getLogPriorTerm()
for each
parameter of this transition element. The results are added to the array
gradient
using the index start
.
gradient
- the array of gradientsstart
- the start index in the gradient
array used to add
partial derivations for the parametersoffset
public double getMinimalHyperparameter()
TransitionElement
.
TransitionElement
public double getLogPosteriorFromStatistic()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |