Package jazzparser :: Package utils :: Package nltk :: Package ngram :: Module baumwelch
[hide private]
[frames] | no frames]

Module baumwelch

source code

Unsupervised EM training for HMMs that use jazzparser.utils.nltk.ngram.NgramModel as their base implementation. This is a generic implementation of the Baum-Welch algorithm for EM training of HMMs. BaumWelchTrainer should be subclassed to override anything that needs to be customized for the model type.


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  BaumWelchTrainer
Class with methods to retrain an HMM using the Baum-Welch EM algorithm.
  BaumWelchTrainingError
Functions [hide private]
 
sequence_updates(sequence, last_model, empty_arrays, array_ids, update_initial=True)
Evaluates the forward/backward probability matrices for a single sequence under the model that came from the previous iteration and returns matrices that contain the updates to be made to the distributions during this iteration.
source code
Variables [hide private]
  ADD_SMALL = 1e-06
  __package__ = 'jazzparser.utils.nltk.ngram'
Function Details [hide private]

sequence_updates(sequence, last_model, empty_arrays, array_ids, update_initial=True)

source code 

Evaluates the forward/backward probability matrices for a single sequence under the model that came from the previous iteration and returns matrices that contain the updates to be made to the distributions during this iteration.

This is wrapped up in a function so it can be run in parallel for each sequence. Once all sequences have been evaluated, the results are combined and model updated.

Parameters:
  • update_initial (bool) - usually you want to update all distributions, including the initial state distribution. If update_initial=False, the initial state distribution updates won't be made for this sequence. We want this when the sequence is actually a non-initial fragment of a longer sequence