Package jazzparser :: Package misc :: Package raphsto :: Module train :: Class RaphstoBaumWelchUnigramTrainer
[hide private]
[frames] | no frames]

Class RaphstoBaumWelchUnigramTrainer

source code

             object --+    
                      |    
RaphstoBaumWelchTrainer --+
                          |
                         RaphstoBaumWelchUnigramTrainer

Class with methods to retrain a Raphsto model using the Baum-Welch EM algorithm. Special trainer to train unigram models. That is, it doesn't update the transition distribution.

Instance Methods [hide private]
 
train(self, emissions, max_iterations=None, convergence_logprob=None, logger=None, processes=1, save=True, save_intermediate=False)
Performs unsupervised training using Baum-Welch EM.
source code
 
update_model(self, model, save=True)
Replaces the distributions of the saved model with those of the given model and saves it.
source code

Inherited from RaphstoBaumWelchTrainer: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  MODEL_TYPES = [<class 'jazzparser.misc.raphsto.RaphstoHmmUnigr...

Inherited from RaphstoBaumWelchTrainer: OPTIONS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

train(self, emissions, max_iterations=None, convergence_logprob=None, logger=None, processes=1, save=True, save_intermediate=False)

source code 

Performs unsupervised training using Baum-Welch EM.

This is an instance method, because it is performed on a model that has already been initialized. You might, for example, create such a model using initialize_chord_types.

This is based on the training procedure in NLTK for HMMs: nltk.tag.hmm.HiddenMarkovModelTrainer.train_unsupervised.

Parameters:
  • emissions (list of lists of emissions) - training data. Each element is a list of emissions representing a sequence in the training data. Each emission is an emission like those used for jazzparser.misc.raphsto.RaphstoHmm.emission_log_probability, i.e. a list of note observations
  • max_iterations (int) - maximum number of iterations to allow for EM (default 100). Overrides the corresponding module option
  • convergence_logprob (float) - maximum change in log probability to consider convergence to have been reached (default 1e-3). Overrides the corresponding module option
  • logger (logging.Logger) - a logger to send progress logging to
  • processes (int) - number processes to spawn. A pool of this many processes will be used to compute distribution updates for sequences in parallel during each iteration.
  • save (bool) - save the model at the end of training
  • save_intermediate (bool) - save the model after each iteration. Implies save
Overrides: RaphstoBaumWelchTrainer.train

update_model(self, model, save=True)

source code 

Replaces the distributions of the saved model with those of the given model and saves it.

Parameters:
  • save (bool) - save the model. Otherwise just updates the distributions.
Overrides: RaphstoBaumWelchTrainer.update_model

Class Variable Details [hide private]

MODEL_TYPES

Value:
[<class 'jazzparser.misc.raphsto.RaphstoHmmUnigram'>]