Package cc.mallet.grmm.inference

Examples of cc.mallet.grmm.inference.JunctionTreeInferencer


   * Computes the exact entropy of a factor graph distribution using the junction tree algorithm.
   *  If the model is intractable, then this method won't return a number anytime soon.
   */
  public static double entropy (FactorGraph mdl)
  {
    JunctionTreeInferencer inf = new JunctionTreeInferencer ();
    inf.computeMarginals (mdl);
    JunctionTree jt = inf.lookupJunctionTree ();
    return jt.entropy ();
  }
View Full Code Here


   * @param mdl2
   * @return KL(mdl1||mdl2)
   */
  public static double KL (FactorGraph mdl1, FactorGraph mdl2)
  {
    JunctionTreeInferencer inf1 = new JunctionTreeInferencer ();
    inf1.computeMarginals (mdl1);
    JunctionTree jt1 = inf1.lookupJunctionTree ();

    JunctionTreeInferencer inf2 = new JunctionTreeInferencer ();
    inf2.computeMarginals (mdl2);
    JunctionTree jt2 = inf2.lookupJunctionTree ();

    double entropy = jt1.entropy ();
    double energy = 0;

    for (Iterator it = jt2.clusterPotentials ().iterator(); it.hasNext();) {
View Full Code Here

      mdl.addFactor (v1, v2, ptlarr);
    }

    // STEP 2: Compute marginals

    Inferencer inf = new JunctionTreeInferencer ();
    inf.computeMarginals (mdl);

    // STEP 3: Collect the results
    //   We'll just print them out

    for (int varnum = 0; varnum < allVars.length; varnum++) {
      Variable var = allVars[varnum];
      Factor ptl = inf.lookupMarginal (var);
      for (AssignmentIterator it = ptl.assignmentIterator (); it.hasNext (); it.advance()) {
        int outcome = it.indexOfCurrentAssn ();
        System.out.println (var+"  "+outcome+"   "+ptl.value (it));
      }
      System.out.println ();
View Full Code Here

      mdl.addFactor (v1, v2, ptlarr);
    }

    // STEP 2: Compute marginals

    Inferencer inf = new JunctionTreeInferencer ();
    inf.computeMarginals (mdl);

    // STEP 3: Collect the results
    //   We'll just print them out

    for (int varnum = 0; varnum < allVars.length; varnum++) {
      Variable var = allVars[varnum];
      Factor ptl = inf.lookupMarginal (var);
      for (AssignmentIterator it = ptl.assignmentIterator (); it.hasNext ();) {
        int outcome = it.indexOfCurrentAssn ();
        System.out.println (var+"  "+outcome+"   "+ptl.value (it));
      }
      System.out.println ();
View Full Code Here

TOP

Related Classes of cc.mallet.grmm.inference.JunctionTreeInferencer

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.