
cc.mallet.grmm.inference.gbp.ParentChildGBP Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcore-mallet-2.0.9 Show documentation
Show all versions of jcore-mallet-2.0.9 Show documentation
MALLET is a Java-based package for statistical natural language processing, document classification, clustering, topic modeling, information extraction, and other machine learning applications to text.
The newest version!
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept.
This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).
http://www.cs.umass.edu/~mccallum/mallet
This software is provided under the terms of the Common Public License,
version 1.0, as published by http://www.opensource.org. For further
information, see the file `LICENSE' included with this distribution. */
package cc.mallet.grmm.inference.gbp;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.*;
import cc.mallet.grmm.inference.AbstractInferencer;
import cc.mallet.grmm.types.*;
import cc.mallet.util.MalletLogger;
import cc.mallet.util.Timing;
/**
* Created: May 27, 2005
*
* @author = MAX_ITER) {
logger.warning ("***WARNING: GBP not converged!");
}
}
private RegionEdge[] chooseMessageSendingOrder ()
{
List l = new ArrayList ();
for (Iterator it = rg.edgeIterator (); it.hasNext();) {
RegionEdge edge = (RegionEdge) it.next ();
l.add (edge);
}
Collections.sort (l, new Comparator () {
public int compare (Object o1, Object o2)
{
RegionEdge e1 = (RegionEdge) o1;
RegionEdge e2 = (RegionEdge) o2;
int l1 = e1.to.vars.size();
int l2 = e2.to.vars.size();
return Double.compare (l1, l2);
};
});
return (RegionEdge[]) l.toArray (new RegionEdge [l.size()]);
}
private boolean hasConverged ()
{
for (Iterator it = rg.edgeIterator (); it.hasNext();) {
RegionEdge edge = (RegionEdge) it.next ();
Factor oldMsg = oldMessages.getMessage (edge.from, edge.to);
Factor newMsg = newMessages.getMessage (edge.from, edge.to);
if (oldMsg == null) {
assert newMsg == null;
} else {
if (!oldMsg.almostEquals (newMsg, THRESHOLD)) {
/*
//xxx debug
if (sender instanceof SparseMessageSender)
System.out.println ("NOT CONVERGED:\n"+newMsg+"\n.......");
*/
return false;
}
}
}
return true;
}
public void dump ()
{
for (Iterator it = rg.edgeIterator (); it.hasNext();) {
RegionEdge edge = (RegionEdge) it.next ();
Factor newMsg = newMessages.getMessage (edge.from, edge.to);
System.out.println ("Message: "+edge.from+" --> "+edge.to+" "+newMsg);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy