summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-13 19:36:52 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-13 19:36:52 +0000
commitb76e0f2213897effb4291822aed2c758a16ffaac (patch)
tree158fe175b20d79408bb43441ef0e2f53272d8411
parentd50ac9af0ab3a082dd97c1da2de36cd743709e3e (diff)
Changed initialisation
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@238 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r--gi/posterior-regularisation/prjava/src/arr/F.java8
-rw-r--r--gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java2
2 files changed, 9 insertions, 1 deletions
diff --git a/gi/posterior-regularisation/prjava/src/arr/F.java b/gi/posterior-regularisation/prjava/src/arr/F.java
index 79de5d1a..2201179e 100644
--- a/gi/posterior-regularisation/prjava/src/arr/F.java
+++ b/gi/posterior-regularisation/prjava/src/arr/F.java
@@ -15,7 +15,7 @@ public class F {
double z = 0;
for (int i = 0; i < probs.length; ++i)
{
- probs[i] = 3 + rng.nextDouble();
+ probs[i] = 1e2 + rng.nextDouble();
if (normalise)
z += probs[i];
}
@@ -25,6 +25,12 @@ public class F {
probs[i] /= z;
}
+ public static void uniform(double probs[])
+ {
+ for (int i = 0; i < probs.length; ++i)
+ probs[i] = 1.0 / probs.length;
+ }
+
public static void l1normalize(double [] a){
double sum=0;
for(int i=0;i<a.length;i++){
diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java
index 68148248..1f73764e 100644
--- a/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java
+++ b/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java
@@ -42,6 +42,7 @@ public class PhraseCluster {
for(double [][]i:emit)
for(double []j:i)
arr.F.randomise(j, true);
+
for(double []j:pi)
arr.F.randomise(j, true);
}
@@ -188,6 +189,7 @@ public class PhraseCluster {
private double KL_symmetric_dirichlet(double[] q, double alpha)
{
// assumes that zeros in q are structural & should be skipped
+ // FIXME: asssumption doesn't hold
double p0 = alpha;
double q0 = 0;