Package cc.mallet.grmm.types

Examples of cc.mallet.grmm.types.Factor


      Assignment assn = unrolled.getAssignment ();
      for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) {
        ACRF.UnrolledVarSet clique = (ACRF.UnrolledVarSet) it.next();
        System.out.println("Clique "+clique);
        dumpAssnForClique (assn, clique);
        Factor ptl = unrolled.factorOf (clique);
        System.out.println("Value = "+ptl.value (assn));
        System.out.println(ptl);
      }
    }
View Full Code Here


  public static void addAllFactors (FactorGraph mdl, List regions)
  {
    for (Iterator it = regions.iterator (); it.hasNext ();) {
      Region region = (Region) it.next ();
      for (Iterator pIt = mdl.factorsIterator (); pIt.hasNext();) {
        Factor ptl = (Factor) pIt.next ();
        if (region.vars.containsAll (ptl.varSet ())) {
          region.factors.add (ptl);
        }
      }
    }
  }
View Full Code Here

    public List computeBaseRegions (FactorGraph mdl)
    {
      List regions = new ArrayList (mdl.factors ().size ());
      for (Iterator it = mdl.factorsIterator (); it.hasNext ();) {
        Factor ptl =  (Factor) it.next ();
        regions.add (new Region (ptl));
      }
      removeSubsumedRegions (regions);
      addAllFactors (mdl, regions);
      return regions;
View Full Code Here

  {
    Variable[] vars = new Variable[] { new Variable (3), new Variable (3), new Variable (3) };

    Variable[] vars1 = new Variable[]{ vars[0], vars[1] };
    double[] vals1 = new double[] { 0, 0.2, 0.8, 0, 0.7, 0.3, 0, 0.5, 0.5 };
    Factor tbl1 = new TableFactor (vars1, vals1);

    Variable[] vars2 = new Variable[]{ vars[1], vars[2] };
    double[] vals2 = new double[] { 0.2, 0.2, 0.8, 0.7, 0, 0.7, 0.3, 0, 0.5 };
    Factor tbl2 = new TableFactor (vars2, vals2);

    FactorGraph fg = new FactorGraph ();
    fg.multiplyBy (tbl1);
    fg.multiplyBy (tbl2);
    System.out.println (fg.dumpToString ());
View Full Code Here

    if (parent == null) {
      throw new UnsupportedOperationException
              ("No parent cluster in " + jt + " for clique " + varSet);
    }

    Factor cpf = jt.getCPF (parent);
    if (logger.isLoggable (Level.FINER)) {
      logger.finer ("Lookup jt marginal: clique " + varSet + " cluster " + parent);
      logger.finest ("  cpf " + cpf);
    }

    Factor marginal = strategy.extractBelief (cpf, varSet);
    marginal.normalize ();

    return marginal;
  }
View Full Code Here

  public Factor lookupMarginal (JunctionTree jt, Variable var)
  {
    if (jt == null) { throw new IllegalStateException ("Call computeMarginals() first."); }

    VarSet parent = jt.findParentCluster (var);
    Factor cpf = jt.getCPF (parent);
    if (logger.isLoggable (Level.FINER)) {
      logger.finer ("Lookup jt marginal: var " + var + " cluster " + parent);
      logger.finest (" cpf " + cpf);
    }

    Factor marginal = strategy.extractBelief (cpf, new HashVarSet (new Variable[] { var }));
    marginal.normalize ();

    return marginal;
  }
View Full Code Here

TOP

Related Classes of cc.mallet.grmm.types.Factor

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.