cc.mallet.fst
Class CRF.Factors

java.lang.Object
  extended by cc.mallet.fst.CRF.Factors
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
CRF

public static class CRF.Factors
extends java.lang.Object
implements java.io.Serializable

A simple, transparent container to hold the parameters or sufficient statistics for the CRF.

See Also:
Serialized Form

Nested Class Summary
 class CRF.Factors.Incrementor
          Instances of this inner class can be passed to various inference methods, which can then gather/increment sufficient statistics counts into the containing Factor instance.
 class CRF.Factors.WeightedIncrementor
           
 
Field Summary
 double[] defaultWeights
           
 double[] finalWeights
           
 double[] initialWeights
           
 Alphabet weightAlphabet
           
 SparseVector[] weights
           
 boolean[] weightsFrozen
           
 
Constructor Summary
CRF.Factors()
          Construct a new empty Factors with a new empty weightsAlphabet, 0-length initialWeights and finalWeights, and the other arrays null.
CRF.Factors(CRF.Factors other)
          Construct new Factors by mimicking the structure of the other one, but with zero values.
CRF.Factors(CRF.Factors other, boolean cloneAlphabet)
          Construct new Factors by copying the other one.
CRF.Factors(CRF crf)
          Construct a new Factors with the same structure as the parameters of 'crf', but with values initialized to zero.
 
Method Summary
 void assertNotNaN()
           
 void assertNotNaNOrInfinite()
           
 double gaussianPrior(double variance)
          Return the log(p(parameters)) according to a zero-mean Gaussian with given variance.
 int getNumFactors()
           
 double getParameter(int index)
           
 void getParameters(double[] buffer)
           
 double getParametersAbsNorm()
           
 double hyberbolicPrior(double slope, double sharpness)
          Return the log(p(parameters)) according to a a hyperbolic curve that is a smooth approximation to an L1 prior.
 void plusEquals(CRF.Factors other, double factor)
           
 void plusEquals(CRF.Factors other, double factor, boolean obeyWeightsFrozen)
           
 void plusEqualsGaussianPriorGradient(CRF.Factors other, double variance)
           
 void plusEqualsHyperbolicPriorGradient(CRF.Factors other, double slope, double sharpness)
           
 void setParameter(int index, double value)
           
 void setParameters(double[] buff)
           
 boolean structureMatches(CRF.Factors other)
           
 void zero()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weightAlphabet

public Alphabet weightAlphabet

weights

public SparseVector[] weights

defaultWeights

public double[] defaultWeights

weightsFrozen

public boolean[] weightsFrozen

initialWeights

public double[] initialWeights

finalWeights

public double[] finalWeights
Constructor Detail

CRF.Factors

public CRF.Factors()
Construct a new empty Factors with a new empty weightsAlphabet, 0-length initialWeights and finalWeights, and the other arrays null.


CRF.Factors

public CRF.Factors(CRF.Factors other)
Construct new Factors by mimicking the structure of the other one, but with zero values. Always simply point to the other's Alphabet; do not clone it.


CRF.Factors

public CRF.Factors(CRF.Factors other,
                   boolean cloneAlphabet)
Construct new Factors by copying the other one.


CRF.Factors

public CRF.Factors(CRF crf)
Construct a new Factors with the same structure as the parameters of 'crf', but with values initialized to zero. This method is typically used to allocate storage for sufficient statistics, expectations, constraints, etc.

Method Detail

getNumFactors

public int getNumFactors()

zero

public void zero()

structureMatches

public boolean structureMatches(CRF.Factors other)

assertNotNaN

public void assertNotNaN()

assertNotNaNOrInfinite

public void assertNotNaNOrInfinite()

plusEquals

public void plusEquals(CRF.Factors other,
                       double factor)

plusEquals

public void plusEquals(CRF.Factors other,
                       double factor,
                       boolean obeyWeightsFrozen)

gaussianPrior

public double gaussianPrior(double variance)
Return the log(p(parameters)) according to a zero-mean Gaussian with given variance.


plusEqualsGaussianPriorGradient

public void plusEqualsGaussianPriorGradient(CRF.Factors other,
                                            double variance)

hyberbolicPrior

public double hyberbolicPrior(double slope,
                              double sharpness)
Return the log(p(parameters)) according to a a hyperbolic curve that is a smooth approximation to an L1 prior.


plusEqualsHyperbolicPriorGradient

public void plusEqualsHyperbolicPriorGradient(CRF.Factors other,
                                              double slope,
                                              double sharpness)

getParametersAbsNorm

public double getParametersAbsNorm()

getParameters

public void getParameters(double[] buffer)

getParameter

public double getParameter(int index)

setParameters

public void setParameters(double[] buff)

setParameter

public void setParameter(int index,
                         double value)