|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.algorithms.optimization.DifferentiableFunction
de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior
de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.CompositeLogPrior
public class CompositeLogPrior
This class implements a composite prior that can be used for DifferentiableStatisticalModel. The prior for each
DifferentiableStatisticalModel should be the (transformed) prior of the corresponding generative model. So e.g. for a
PWM one should use an product of Dirichlets. The prior is more or less implemented in the
DifferentiableStatisticalModel. For the class variables the prior uses a (transformed) Dirichlet with hyperparameters
equal to the ESS of the classes.
If this class uses only the free parameters the class implements a real prior the is normalized to 1. If it used all
parameters the function does not have (and is in general) not normalized to 1. Fortunately this is no problem, since
it can be shown the it makes no difference in the optimization.
DifferentiableStatisticalModel
,
DifferentiableStatisticalModel.addGradientOfLogPriorTerm(double[], int)
,
DifferentiableStatisticalModel.getLogPriorTerm()
Field Summary |
---|
Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior |
---|
UNKNOWN |
Constructor Summary | |
---|---|
CompositeLogPrior()
The main constructor. |
|
CompositeLogPrior(StringBuffer xml)
The constructor for the Storable interface. |
Method Summary | |
---|---|
void |
addGradientFor(double[] params,
double[] grad)
Adds the gradient of the log-prior using the current parameters to a given vector. |
double |
evaluateFunction(double[] x)
Evaluates the function at a certain vector (in mathematical sense) x . |
int |
getDimensionOfScope()
Returns the dimension of the scope of the Function . |
String |
getInstanceName()
Returns a short instance name. |
CompositeLogPrior |
getNewInstance()
This method returns an empty new instance of the current prior. |
void |
set(boolean freeParameters,
DifferentiableSequenceScore... funs)
Resets all pre-computed values to their initial values using the DifferentiableSequenceScore s funs . |
StringBuffer |
toXML()
Encodes the prior as an XML representation. |
Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior |
---|
evaluateGradientOfFunction |
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 |
Constructor Detail |
---|
public CompositeLogPrior()
public CompositeLogPrior(StringBuffer xml)
Storable
interface.
xml
- the StringBufferMethod Detail |
---|
public void set(boolean freeParameters, DifferentiableSequenceScore... funs) throws Exception
LogPrior
DifferentiableSequenceScore
s funs
.
set
in class LogPrior
freeParameters
- the switch for using only the free parameters or all
parameters in a DifferentiableSequenceScore
funs
- the DifferentiableSequenceScore
s for the prior
Exception
- if the DifferentiableSequenceScore
s could not be setpublic void addGradientFor(double[] params, double[] grad) throws EvaluationException
LogPrior
addGradientFor
in class LogPrior
params
- the parametersgrad
- the vector
EvaluationException
- if the gradient could not be evaluatedpublic double evaluateFunction(double[] x) throws DimensionException, EvaluationException
Function
x
.
x
- the current vector
DimensionException
- if dim(x) != n
, with EvaluationException
- if there was something wrong during the evaluation of the
functionpublic int getDimensionOfScope()
Function
Function
.
n
with
public CompositeLogPrior getNewInstance() throws CloneNotSupportedException
LogPrior
DifferentiableSequenceScore
s that may be inside the instance. The DifferentiableSequenceScore
s must be
set by an invocation of the method
LogPrior.set(boolean, DifferentiableSequenceScore...)
.
getNewInstance
in class LogPrior
CloneNotSupportedException
- if something went wrong while cloningLogPrior.set(boolean, DifferentiableSequenceScore...)
public StringBuffer toXML()
LogPrior
LogPrior.set(boolean, DifferentiableSequenceScore...)
has to be invoked after decoding.
toXML
in interface Storable
toXML
in class LogPrior
public String getInstanceName()
LogPrior
getInstanceName
in class LogPrior
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |