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

Class RaphstoBaumWelchTrainer

source code

object --+
         |
        RaphstoBaumWelchTrainer
Known Subclasses:

Class with methods to retrain a Raphsto model using the Baum-Welch EM algorithm.

Instance Methods [hide private]
 
__init__(self, model, options={})
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
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 object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  OPTIONS = [ModuleOption('max_iterations', filter= int, help_te...
  MODEL_TYPES = [<class 'jazzparser.misc.raphsto.RaphstoHmm'>, <...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, model, options={})
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

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

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.

Class Variable Details [hide private]

OPTIONS

Value:
[ModuleOption('max_iterations', filter= int, help_text= "Number of tra\
ining iterations to give up after " "if we don't reach convergence bef\
ore.", usage= "max_iterations=N, where N is an integer", default= 100)\
, ModuleOption('convergence_logprob', filter= float, help_text= "Diffe\
rence in overall log probability of the " "training data made by one i\
teration after which we " "consider the training to have converged.", \
usage= "convergence_logprob=X, where X is a small floating " "point nu\
mber (e.g. 1e-3)", default= 1e-3),]

MODEL_TYPES

Value:
[<class 'jazzparser.misc.raphsto.RaphstoHmm'>,
 <class 'jazzparser.misc.raphsto.RaphstoHmmThreeChord'>,
 <class 'jazzparser.misc.raphsto.RaphstoHmmFourChord'>]