CMP 243 Homework 5, part 1

Due: Nov. 18

Training HMMs

NOTE: SOME BUGS WERE FOUND IN THIS PART OF THE HOMEWORK. See bugs.

Thanks to Jose for helping to prepare this. This homework will give you some experience training simple HMMs, using the software provided by Anders Krogh. The files needed are in the directory /cse/guests/krogh/book/ahmm/dice on the barnyard machines. Copy the following files from the above directory: dice.ini, dice.imod, 300random_rolls.seq, README, and random_rolls.awk to your home directory, or the directory you my have for this class. Also read the TRAINAHMM part of the AHMM.documentaion found in /cse/guests/krogh/book/ahmm/AHMM.documentaion .

Notice that there is no dice.mod file, as in homework4.part2. We will train an HMM, which will produce the dice.mod file. The file AHMM.documentaion explains how decodeahmm, testahmm, and trainahmm work. Recall that these three programs are located in the directory /cse/guests/krogh/book/ahmm/bin/OSF1. You may want to add this directory to your UNIX path; otherwise you have to type all this every time you run one of the programs.

To train an HMM use the command "trainahmm dice" (or prepend /cse/guests/krogh/book/ahmm/bin/OSF1 if you didn't add this to your UNIX path.) You must be on one of the barnyard machines, since these programs are complied for the DEC alpha (otherwise you need to look in one of the alternate directories in /cse/guests/krogh/book/ahmm/bin to find the executable version for your machine.)

As described in the AHMM.documentaion file the trainahmm program will use the dice.imod file and dice.ini file to produce a dice.mod file. Try it, and compare the dice.mod file produced to the dice.imod file.

  1. Try training several times and each time look at the dice.mod file. Are there any changes? Describe.
  2. Now open up the dice.ini file and and remove the ";" in front of the word "Seed". Now train two more times. Does the dice.mod file change each time? (This change causes the training algorithm to use the same random seed for every run to control the noise added during training.)
  3. Using the last model you trained, decode data1, data2, data3(from homework4.part2) with the Viterbi and Posterior algorithms, as in homework4.part2. Compare these results with homework4.part2 results. Are results different? If so, why?
  4. Now let's play with varying the initial model used to train the HMM. Open the dice.imod file. Notice that there are no probabilities assigned to any of the transitions. Try assigning the following probabilities in the begin state transitions:
    fair: 0.99
    loaded: 0.01;
    
    Note that all other transitions for other states must be blank. Now retrain the dice model. repeat this experiment two more times, using (0.5, 0.5) and (0.01, 0.99) as values for these transitions, resp. What happens to the dice.mod file after retraining, anything strange or unexpected?
  5. Let's see what happens if we have a larger training set. We'll try training with a set of 5000 random rolls. This can be done by opening the random_rolls.awk file and replacing the 300 with 5000 and deleting the line that contains "print stateseq". Then use the following command
    gawk -f  random_rolls.awk > 5000random_rolls.seq
    
    This will produce the file 5000random_rolls.seq. Also open the dice.ini file and replace the obsfile 300random_rolls.seq with 5000random_rolls.seq. Now retrain the dice model and compare the estimated probabilities to those obtained using only 300 random rolls. Use the starting probabilities of 0.5 and 0.5 from the previous part of the homework. Say how the models differ, if they differ significantly at all.

Questions regarding about page content should be directed to haussler@cse.ucsc.edu.
Last modified Nov. 13, 1996.

Back to the CMP 243 Class Page.