summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 19:39:33 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 19:39:33 +0000
commit78763d1966bc6bb7702906b73aeb6b154577418e (patch)
treece0830094798a46e28e51a7f71c897a30eabfabf /gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
parent126ac86b48998f4678c11315995ad73ae3dcd842 (diff)
Prettyfied output regarding optimization failure.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@210 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java')
-rw-r--r--gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
index 3314f74a..f24b903d 100644
--- a/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
+++ b/gi/posterior-regularisation/prjava/src/phrase/PhraseObjective.java
@@ -22,7 +22,7 @@ public class PhraseObjective extends ProjectedObjective
{
static final double GRAD_DIFF = 0.00002;
static double INIT_STEP_SIZE = 300;
- static double VAL_DIFF = 1e-4; // FIXME needs to be tuned - and this might be too weak
+ static double VAL_DIFF = 1e-6; // FIXME needs to be tuned - and this might be too weak
static int ITERATIONS = 100;
//private double c1=0.0001; // wolf stuff
//private double c2=0.9;
@@ -164,7 +164,9 @@ public class PhraseObjective extends ProjectedObjective
return q;
}
- public void optimizeWithProjectedGradientDescent(){
+ public int iterations = 0;
+
+ public boolean optimizeWithProjectedGradientDescent(){
LineSearchMethod ls =
new ArmijoLineSearchMinimizationAlongProjectionArc
(new InterpolationPickFirstStep(INIT_STEP_SIZE));
@@ -181,13 +183,14 @@ public class PhraseObjective extends ProjectedObjective
compositeStop.add(stopValue);
optimizer.setMaxIterations(ITERATIONS);
updateFunction();
- boolean succed = optimizer.optimize(this,stats,compositeStop);
+ boolean success = optimizer.optimize(this,stats,compositeStop);
+ iterations += optimizer.getCurrentIteration();
// System.out.println("Ended optimzation Projected Gradient Descent\n" + stats.prettyPrint(1));
- if(succed){
+ //if(succed){
//System.out.println("Ended optimization in " + optimizer.getCurrentIteration());
- }else{
- System.out.println("Failed to optimize");
- }
+ //}else{
+// System.out.println("Failed to optimize");
+ //}
lambda[phrase]=parameters;
// ps.println(Arrays.toString(parameters));
@@ -195,6 +198,7 @@ public class PhraseObjective extends ProjectedObjective
// ps.println(Arrays.toString(q[edge]));
// }
+ return success;
}
public double KL_divergence()