Examples of valueAtLocation()


Examples of cc.mallet.types.IndexedSparseVector.valueAtLocation()

  public void testCloneMatrixZeroed ()
  {
    IndexedSparseVector s = (IndexedSparseVector) s1.cloneMatrixZeroed ();
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == 0.0);
      assertTrue (s.indexAtLocation (i) == idxs [i]);
    }
  }

  public void testEmptyLocations ()
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

      // I.e., if 20, it would be as if the document had 20 words.
      instanceWeight *= docLengthNormalization / oneNorm;
    assert (instanceWeight > 0 && !Double.isInfinite(instanceWeight));
    for (int lpos = 0; lpos < labeling.numLocations(); lpos++) {
      int li = labeling.indexAtLocation (lpos);
      double labelWeight = labeling.valueAtLocation (lpos);
      if (labelWeight == 0) continue;
      //System.out.println ("NaiveBayesTrainer me.increment "+ labelWeight * instanceWeight);
      me[li].increment (fv, labelWeight * instanceWeight);
      // This relies on labelWeight summing to 1 over all labels
      pe.increment (li, labelWeight * instanceWeight);
 
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

      assert(labeling.numLocations() == trainingSet.getTargetAlphabet().size());
      for (int pos = 0; pos < labeling.numLocations(); pos++){
        MatrixOps.rowPlusEquals (constraints, numFeatures,
                     labeling.indexAtLocation(pos),
                     fv,
                     instanceWeight*labeling.valueAtLocation(pos));
      }

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";

      boolean hasNaN = false;
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

        FeatureVector fv = (FeatureVector) instance.getData ();

        value = 0.0;
        for(int pos = 0; pos < labeling.numLocations(); pos++) { //loop, added by Limin Yao
          int ll = labeling.indexAtLocation(pos);
          if (scores[ll] == && labeling.valueAtLocation(pos) > 0) {
            logger.warning ("Instance "+instance.getSource() + " has infinite value; skipping value and gradient");
            cachedValue = Double.NEGATIVE_INFINITY;
            cachedValueStale = false;
            return cachedValue;
          }
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

            logger.warning ("Instance "+instance.getSource() + " has infinite value; skipping value and gradient");
            cachedValue = Double.NEGATIVE_INFINITY;
            cachedValueStale = false;
            return cachedValue;
          }
          else if (labeling.valueAtLocation(pos) != 0) {
            value -= (instanceWeight * labeling.valueAtLocation(pos) * Math.log (scores[ll]));
          }
        }     

        if (Double.isNaN(value)) {
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

            cachedValue = Double.NEGATIVE_INFINITY;
            cachedValueStale = false;
            return cachedValue;
          }
          else if (labeling.valueAtLocation(pos) != 0) {
            value -= (instanceWeight * labeling.valueAtLocation(pos) * Math.log (scores[ll]));
          }
        }     

        if (Double.isNaN(value)) {
          logger.fine ("MaxEntOptimizableByLabelDistribution: Instance " + instance.getName() +
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

     
      for (int pos = 0; pos < labeling.numLocations(); pos++){
        MatrixOps.rowPlusEquals (constraints, numFeatures,
                     labeling.indexAtLocation(pos),
                     fv,
                     instanceWeight*labeling.valueAtLocation(pos));
      }

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";

      boolean hasNaN = false;
View Full Code Here

Examples of cc.mallet.types.Labeling.valueAtLocation()

        FeatureVector fv = (FeatureVector) instance.getData ();

            value = 0.0;
        for(int pos = 0; pos < labeling.numLocations(); pos++) { //loop, added by Limin Yao
          int ll = labeling.indexAtLocation(pos);
          value -= (instanceWeight * labeling.valueAtLocation(pos) * Math.log (scores[ll]));         
        }     

        if (Double.isNaN(value)) {
          logger.fine ("MaxEntOptimizableByLabelDistribution: Instance " + instance.getName() +
                 "has NaN value.");
View Full Code Here

Examples of cc.mallet.types.Matrix.valueAtLocation()

  public Matrix getValueMatrix ()
  {
    Matrix logProbs = (Matrix) probs.cloneMatrix ();
    for (int loc = 0; loc < probs.numLocations (); loc++) {
      logProbs.setValueAtLocation (loc, Math.exp (logProbs.valueAtLocation (loc)));
    }
    Flops.exp (probs.numLocations ());
    return logProbs;
  }
View Full Code Here

Examples of cc.mallet.types.Matrix.valueAtLocation()

  public Matrix getLogValueMatrix ()
  {
    Flops.log (probs.numLocations ());
    Matrix logProbs = (Matrix) probs.cloneMatrix ();
    for (int loc = 0; loc < probs.numLocations (); loc++) {
      logProbs.setValueAtLocation (loc, Math.log (logProbs.valueAtLocation (loc)));
    }
    return logProbs;
  }

  public double valueAtLocation (int idx)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.