Examples of valueAtLocation()


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

  public static LogTableFactor makeFromMatrix (Variable[] vars, SparseMatrixn values)
  {
    SparseMatrixn logValues = (SparseMatrixn) values.cloneMatrix ();
    for (int i = 0; i < logValues.numLocations (); i++) {
      logValues.setValueAtLocation (i, Math.log (logValues.valueAtLocation (i)));
    }
    Flops.log (logValues.numLocations ());
    return new LogTableFactor (vars, logValues);
  }
View Full Code Here

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

        SparseVector theseConstraints = defaultConstraints [tidx];
        SparseVector theseExpectations = defaultExpectations [tidx];
        for (int j = 0; j < theseWeights.numLocations(); j++) {
          double weight = theseWeights.valueAtLocation (j);
          double constraint = theseConstraints.valueAtLocation (j);
          double expectation = theseExpectations.valueAtLocation (j);
          if (printGradient) {
            System.out.println(" gradient ["+gidx+"] = "+constraint+" (ctr) - "+expectation+" (exp) - "+
                             (weight / gaussianPriorVariance)+" (reg)  [feature=DEFAULT]");
          }
          grad [gidx++] = constraint - expectation - (weight / gaussianPriorVariance);
View Full Code Here

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

          for (int j = 0; j < thisWeightVec.numLocations(); j++) {
            double w = thisWeightVec.valueAtLocation (j);
            double gradient;  // Computed below

            double constraint = thisConstraintVec.valueAtLocation(j);
            double expectation = thisExpectationVec.valueAtLocation(j);

            /* A parameter may be set to -infinity by an external user.
             * We set gradient to 0 because the parameter's value can
             * never change anyway and it will mess up future calculations
             * on the matrix. */
 
View Full Code Here

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

    SparseVector s5 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s5.plusEqualsSparse (s1);
    for (int i = 0; i < s5.numLocations(); i++) {
      assertEquals (7, s5.indexAtLocation (i));
      assertEquals (3.2, s5.valueAtLocation (i), 0.0);
    }

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
    for (int i = 0; i < s6.numLocations(); i++) {
View Full Code Here

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

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
    for (int i = 0; i < s6.numLocations(); i++) {
      assertEquals (7, s6.indexAtLocation (i));
      assertEquals (10.7, s6.valueAtLocation (i), 0.0);
    }
  }

  public void testDotProduct () {
    SparseVector t1 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
View Full Code Here

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

    SparseVector s = (SparseVector) s1.cloneMatrix ();
    s.incrementValue (5, 0.75);

    double[] ans = new double[] {1, 2.75, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

 
  public void testSetValue ()
View Full Code Here

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

    SparseVector s = (SparseVector) s1.cloneMatrix ();
    s.setValue (5, 0.3);

    double[] ans = new double[] {1, 0.3, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

  public void testDenseSparseVector ()
  {
View Full Code Here

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

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

  public void testPrint ()
View Full Code Here

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

        SparseVector theseConstraints = defaultConstraints [tidx];
        SparseVector theseExpectations = defaultExpectations [tidx];
        for (int j = 0; j < theseWeights.numLocations(); j++) {
          double weight = theseWeights.valueAtLocation (j);
          double constraint = theseConstraints.valueAtLocation (j);
          double expectation = theseExpectations.valueAtLocation (j);
          if (printGradient) {
            System.out.println(" gradient ["+gidx+"] = "+constraint+" (ctr) - "+expectation+" (exp) - "+
                             (weight / gaussianPriorVariance)+" (reg)  [feature=DEFAULT]");
          }
          grad [gidx++] = constraint - expectation - priorScale * (weight / gaussianPriorVariance);
View Full Code Here

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

          for (int j = 0; j < thisWeightVec.numLocations(); j++) {
            double w = thisWeightVec.valueAtLocation (j);
            double gradient;  // Computed below

            double constraint = thisConstraintVec.valueAtLocation(j);
            double expectation = thisExpectationVec.valueAtLocation(j);

            /* A parameter may be set to -infinity by an external user.
             * We set gradient to 0 because the parameter's value can
             * never change anyway and it will mess up future calculations
             * on the matrix. */
 
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.