📄 junctiontreemaxproduct.java
字号:
/* 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 edu.umass.cs.mallet.grmm;import edu.umass.cs.mallet.base.util.MalletLogger;import java.util.logging.Logger;/** * Computes max-marginals of a model using junctiontree algorithm. * * @author Charles Sutton * @version $Id: JunctionTreeMaxProduct.java,v 1.1 2004/07/15 17:53:31 casutton Exp $ */public class JunctionTreeMaxProduct extends JunctionTreeInferencer { private static Logger logger = MalletLogger.getLogger (JunctionTreeMaxProduct.class.getName()); public void computeMarginals (UndirectedModel mdl) { buildJunctionTree (mdl); ViterbiPropagation vp = new ViterbiPropagation (); vp.computeMarginals (jtCurrent); } public DiscretePotential lookupMarginal (Variable var) { Clique parent = jtCurrent.findParentCluster (var); DiscretePotential cpf = jtCurrent.getCPF (parent);// logger.finer ("Lookup jt marginal: var "+var+" cluster "+parent);// logger.finest (" cpf "+cpf); DiscretePotential marginal = cpf.extractMax (var);// logger.finest ("Returning "+marginal); return marginal; } public DiscretePotential lookupMarginal (Clique clique) { Clique parent = jtCurrent.findParentCluster (clique); if (parent == null) { throw new UnsupportedOperationException ("No parent cluster in "+jtCurrent+" for clique "+clique); } DiscretePotential cpf = jtCurrent.getCPF (parent);// logger.finer ("Lookup jt marginal: clique "+clique+" cluster "+parent);// logger.finest (" cpf "+cpf); DiscretePotential marginal = cpf.extractMax (clique);// logger.finest ("Returning "+marginal); return marginal; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -