Package cc.mallet.grmm.types

Examples of cc.mallet.grmm.types.FactorGraph


    super (name);
  }

  public void testEarlyStopping ()
  {
    FactorGraph grid = RandomGraphs.randomAttractiveGrid (5, 0.5, new Random (2413421));
    TRP trp = new TRP (new TRP.IterationTerminator (1));
    trp.setRandomSeed (14312341);

    trp.computeMarginals (grid);

    boolean oneIsDifferent = false;

    // check no exceptions thrown when asking for all marginals,
    //  and check that at least one factors' belief has changed
    //  from the choice at zero iterations.
    for (Iterator it = grid.factorsIterator (); it.hasNext();) {
      Factor f = (Factor) it.next ();
      Factor marg = trp.lookupMarginal (f.varSet ());// test no exception thrown
      if (!marg.almostEquals (f.duplicate ().normalize ())) {
        oneIsDifferent = true;
      }
View Full Code Here


  FactorGraph subMdl;

  public FactorizedRegion (List factors)
  {
    super (varsForFactors (factors), factors);
    subMdl = new FactorGraph ((Variable[]) vars.toArray (new Variable[0]));
    for (Iterator it = factors.iterator (); it.hasNext ();) {
      Factor factor = (Factor) it.next ();
      subMdl.addFactor (factor);
    }
  }
View Full Code Here

    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 ());

    GibbsSampler gs = new GibbsSampler (new Randoms (324123), 10);
    gs.sample (fg, 10)// assert no exception
  }
View Full Code Here

TOP

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

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.