From 925087356b853e2099c1b60d8b757d7aa02121a9 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 2 Oct 2012 00:19:43 -0400 Subject: cdec cleanup, remove bayesian stuff, parsing stuff --- .../prjava/src/phrase/PhraseObjective.java | 224 --------------------- 1 file changed, 224 deletions(-) delete mode 100644 gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java (limited to 'gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java') diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java deleted file mode 100644 index ac73a075..00000000 --- a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java +++ /dev/null @@ -1,224 +0,0 @@ -package phrase; - -import java.util.Arrays; -import java.util.List; - -import optimization.gradientBasedMethods.ProjectedGradientDescent; -import optimization.gradientBasedMethods.ProjectedObjective; -import optimization.gradientBasedMethods.stats.OptimizerStats; -import optimization.linesearch.ArmijoLineSearchMinimizationAlongProjectionArc; -import optimization.linesearch.InterpolationPickFirstStep; -import optimization.linesearch.LineSearchMethod; -import optimization.linesearch.WolfRuleLineSearch; -import optimization.projections.SimplexProjection; -import optimization.stopCriteria.CompositeStopingCriteria; -import optimization.stopCriteria.ProjectedGradientL2Norm; -import optimization.stopCriteria.StopingCriteria; -import optimization.stopCriteria.ValueDifference; -import optimization.util.MathUtils; - -public class PhraseObjective extends ProjectedObjective -{ - static final double GRAD_DIFF = 0.00002; - static double INIT_STEP_SIZE = 300; - static double VAL_DIFF = 1e-8; // tuned to BTEC subsample - static int ITERATIONS = 100; - private PhraseCluster c; - - /**@brief - * for debugging purposes - */ - //public static PrintStream ps; - - /**@brief current phrase being optimzed*/ - public int phrase; - - /**@brief un-regularized posterior - * unnormalized - * p[edge][tag] - * P(tag|edge) \propto P(tag|phrase)P(context|tag) - */ - private double[][]p; - - /**@brief regularized posterior - * q[edge][tag] propto p[edge][tag]*exp(-lambda) - */ - private double q[][]; - private List data; - - /**@brief log likelihood of the associated phrase - * - */ - private double loglikelihood; - private SimplexProjection projection; - - double[] newPoint ; - - private int n_param; - - /**@brief likelihood under p - * - */ - public double llh; - - public PhraseObjective(PhraseCluster cluster, int phraseIdx, double scale, double[] lambda){ - phrase=phraseIdx; - c=cluster; - data=c.c.getEdgesForPhrase(phrase); - n_param=data.size()*c.K; - //System.out.println("Num parameters " + n_param + " for phrase #" + phraseIdx); - - if (lambda==null) - lambda=new double[n_param]; - - parameters = lambda; - newPoint = new double[n_param]; - gradient = new double[n_param]; - initP(); - projection=new SimplexProjection(scale); - q=new double [data.size()][c.K]; - - setParameters(parameters); - } - - private void initP(){ - p=new double[data.size()][]; - for(int edge=0;edgemax) - max=q[edge][tag]; - } - sum+=max; - } - return sum; - } - - public double primal(double scale) - { - return loglikelihood() - KL_divergence() - scale * l1lmax(); - } -} -- cgit v1.2.3