Package cc.mallet.fst
Class CRF.Factors
- java.lang.Object
-
- 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.SerializableA simple, transparent container to hold the parameters or sufficient statistics for the CRF.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCRF.Factors.IncrementorInstances of this inner class can be passed to various inference methods, which can then gather/increment sufficient statistics counts into the containing Factor instance.classCRF.Factors.WeightedIncrementor
-
Field Summary
Fields Modifier and Type Field Description double[]defaultWeightsdouble[]finalWeightsdouble[]initialWeightsAlphabetweightAlphabetSparseVector[]weightsboolean[]weightsFrozen
-
Constructor Summary
Constructors Constructor Description Factors()Construct a new empty Factors with a new empty weightsAlphabet, 0-length initialWeights and finalWeights, and the other arrays null.Factors(CRF crf)Construct a new Factors with the same structure as the parameters of 'crf', but with values initialized to zero.Factors(CRF.Factors other)Construct new Factors by mimicking the structure of the other one, but with zero values.Factors(CRF.Factors other, boolean cloneAlphabet)Construct new Factors by copying the other one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertNotNaN()voidassertNotNaNOrInfinite()doublegaussianPrior(double variance)Return the log(p(parameters)) according to a zero-mean Gaussian with given variance.intgetNumFactors()doublegetParameter(int index)voidgetParameters(double[] buffer)doublegetParametersAbsNorm()doublehyberbolicPrior(double slope, double sharpness)Return the log(p(parameters)) according to a a hyperbolic curve that is a smooth approximation to an L1 prior.voidplusEquals(CRF.Factors other, double factor)voidplusEquals(CRF.Factors other, double factor, boolean obeyWeightsFrozen)voidplusEqualsGaussianPriorGradient(CRF.Factors other, double variance)voidplusEqualsHyperbolicPriorGradient(CRF.Factors other, double slope, double sharpness)voidsetParameter(int index, double value)voidsetParameters(double[] buff)booleanstructureMatches(CRF.Factors other)voidzero()
-
-
-
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
-
Factors
public Factors()
Construct a new empty Factors with a new empty weightsAlphabet, 0-length initialWeights and finalWeights, and the other arrays null.
-
Factors
public 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.
-
Factors
public Factors(CRF.Factors other, boolean cloneAlphabet)
Construct new Factors by copying the other one.
-
Factors
public 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)
-
-