summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordesaicwtf <desaicwtf@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-12 18:54:12 +0000
committerdesaicwtf <desaicwtf@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-12 18:54:12 +0000
commit2f90f9e203da01583ee0b82d4769f25b198835dd (patch)
tree367a6704503a46e986b5b9a75c72df2aa6a85279
parentbd046a0cda7317f9dc2b68a33a0de5e21d7cbb16 (diff)
agreement model prints llh, distance and objective
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@225 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r--gi/posterior-regularisation/prjava/src/phrase/Agree.java22
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;