Package cc.mallet.fst

Examples of cc.mallet.fst.SumLattice


       */
      public void run() {
        int numLabels = stateLabelMap.getNumLabels();
        double[] expectation = new double[numLabels];
        int featureCount = 0;
        SumLattice lattice = null;
        for (int i : lattices.keySet()) {
          // skip if the instance doesn't have any constraints
          if (!constraintBits.get(i)) {
            continue;
          }
          FeatureVectorSequence fvs = (FeatureVectorSequence) ilist.get(i).getData();
          lattice = lattices.get(i);
          assert(lattice != null)
              : "Lattice is null:: " + i + ", size: " + lattices.size();

          // update the number of times this feature occurred in the sequence
          // and the label expectations due to this sequence
          featureCount += getExpectationForInstance(
              fi, fvs, lattice.getGammas(), expectation);
        }
        assert(!MatrixOps.isNaNOrInfinite(expectation));
       
        if (MatrixOps.isNonZero(expectation)) {
          // normalizing label expectations
View Full Code Here


    expectations.zero();

    // now, update the expectations due to each instance for entropy reg.
    for (int ii = 0; ii < data.size(); ii++) {
      FeatureVectorSequence input = (FeatureVectorSequence) data.get(ii).getData();
      SumLattice lattice = new SumLatticeDefault(crf,input, true);

      // udpate the expectations
      EntropyLattice entropyLattice = new EntropyLattice(
          input, lattice.getGammas(), lattice.getXis(), crf,
          incrementor, scalingFactor);
      cachedValue += entropyLattice.getEntropy();
    }
  }
View Full Code Here

TOP

Related Classes of cc.mallet.fst.SumLattice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.