diff options
author | desaicwtf <desaicwtf@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-12 18:54:12 +0000 |
---|---|---|
committer | desaicwtf <desaicwtf@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-12 18:54:12 +0000 |
commit | a753ce95a0c285952fd64d658f2bd4a5c5db8e4c (patch) | |
tree | f50aaf5c7fa221bcb5dfda492eceef0142e82338 /gi/posterior-regularisation | |
parent | 17f8fa666dd0614dbbc520985d0cdcb8b0e69b05 (diff) |
agreement model prints llh, distance and objective
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@225 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation')
-rw-r--r-- | gi/posterior-regularisation/prjava/src/phrase/Agree.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Agree.java b/gi/posterior-regularisation/prjava/src/phrase/Agree.java index 1d56cf18..d5b949b0 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Agree.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Agree.java @@ -17,8 +17,14 @@ public class Agree { Corpus c;
private int K,n_phrases, n_words, n_contexts, n_positions1,n_positions2;
- private double llh;
-
+ /**@brief sum of loglikelihood of two
+ * individual models
+ */
+ public double llh;
+ /**@brief Bhattacharyya distance
+ *
+ */
+ public double bdist;
/**
*
* @param numCluster
@@ -60,10 +66,11 @@ public class Agree { Agree agree=new Agree(numCluster, corpus);
int iter=20;
- double llh=0;
for(int i=0;i<iter;i++){
- llh=agree.EM();
- System.out.println("Iter"+i+", llh: "+llh);
+ agree.EM();
+ System.out.println("Iter"+i+", llh: "+agree.llh+
+ ", divergence:"+agree.bdist+
+ " sum: "+(agree.llh+agree.bdist));
}
File outfile = new File (out);
@@ -90,7 +97,7 @@ public class Agree { double [][]exp_pi2=new double[n_contexts][K];
llh=0;
-
+ bdist=0;
//E
for(int context=0; context< n_contexts; context++){
@@ -102,7 +109,7 @@ public class Agree { double p[]=posterior(edge);
double z = arr.F.l1norm(p);
assert z > 0;
- llh += edge.getCount() * Math.log(z);
+ bdist += edge.getCount() * Math.log(z);
arr.F.l1normalize(p);
int count = edge.getCount();
@@ -147,7 +154,6 @@ public class Agree { arr.F.l1normalize(j);
}
-
model1.emit=exp_emit1;
model1.pi=exp_pi1;
model2.emit=exp_emit2;
|