Baum-Welch training, no change of transition probabilities

128 views
Skip to first unread message

horst.d...@gmail.com

unread,
May 16, 2013, 11:27:26 AM5/16/13
to jahmm-...@googlegroups.com
Hello @all,

I implemented the example of training a HMM as seen on https://code.google.com/p/jahmm/wiki/Example:

OpdfIntegerFactory factory = new OpdfIntegerFactory(2);
Hmm<ObservationInteger> hmm = new Hmm<ObservationInteger>(2, factory);
               
hmm.setPi(0, 0.95);
hmm.setPi(1, 0.05);

hmm.setAij(0, 1, 0.1);
hmm.setAij(0, 0, 0.9);

hmm.setAij(1, 1, 0.3);
hmm.setAij(1, 0, 0.7);

hmm.setOpdf(0, new OpdfInteger(new double[] { 0.95, 0.05 }));
hmm.setOpdf(1, new OpdfInteger(new double[] { 0.2, 0.8 }));

BaumWelchLearner bwl = new BaumWelchLearner();

List<? extends List<? extends ObservationInteger>> sequences = generateSequences(hmm);

Hmm<ObservationInteger> learntHmm = bwl.learn(hmm, sequences);
KullbackLeiblerDistanceCalculator klc = new KullbackLeiblerDistanceCalculator();
for (int i = 0; i < 10; i++) {
System.out.println(i+ " "+ klc.distance(learntHmm, hmm));
learntHmm = bwl.iterate(learntHmm, sequences);
}
System.out.println(hmm.toString());

Unfortunately the transition probabilities (Aij) and initial probabilites (pi) aren't trained:

0 4.433387607481337E-5
1 -3.677524277389917E-6
2 -8.066741651904295E-5
3 5.738735786639495E-5
4 7.034651173119073E-5
5 3.279174771616908E-5
6 -1.722213579545268E-5
7 -9.996262477617393E-5
8 -1.4072998157507759E-5
9 1.7850154324307256E-4
HMM with 2 state(s)

State 0
  Pi: 0.95
  Aij: 0,9 0,1
  Opdf: Integer distribution --- 0,951 0,049

State 1
  Pi: 0.05
  Aij: 0,7 0,3
  Opdf: Integer distribution --- 0,209 0,791


I also have a scenario with 4096 observations and 178109 observation sequences where the state transition and inital probabilites were not trained.
Is there something wrong with the code?

Regards,
Horst

yyec...@gmail.com

unread,
Oct 3, 2013, 8:27:30 AM10/3/13
to jahmm-...@googlegroups.com
Why do you print hmm and not learntHmm?
Reply all
Reply to author
Forward
0 new messages