Package cc.mallet.fst

Class CRF.Factors

  • All Implemented Interfaces:
    Enclosing class:

    public static class CRF.Factors
    extends java.lang.Object
    A simple, transparent container to hold the parameters or sufficient statistics for the CRF.
    See Also:
    Serialized Form
    • Field Detail

      • weightAlphabet

        public Alphabet weightAlphabet
      • 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)