Package jazzparser :: Package misc :: Package chordlabel :: Module baumwelch :: Class HPBaumWelchTrainer
[hide private]
[frames] | no frames]

Class HPBaumWelchTrainer

source code

                                 object --+    
                                          |    
utils.nltk.ngram.baumwelch.BaumWelchTrainer --+
                                              |
                                             HPBaumWelchTrainer

Baum-Welch training for jazzparser.misc.chordlabel.HPChordLabeler models.

Instance Methods [hide private]
 
record_history(self, line)
Stores a line in the history of the model to keep a record of training steps.
source code
 
create_mutable_model(self, model)
Creates a mutable version of the given model.
source code
 
get_empty_arrays(self)
Creates empty arrays to hold the accumulated probabilities during training.
source code
 
get_array_indices(self)
Returns a tuple of the dicts that map labels, emissions, etc to the indices of arrays to which they correspond.
source code
 
sequence_updates_callback(self, result)
Callback for the sequence_updates processes that takes the updates from a single sequence and adds them onto the global update accumulators.
source code
 
update_model(self, arrays, array_ids)
Replaces the distributions of the saved model with the probabilities taken from the arrays of updates.
source code
 
save(self)
Saves the model in self.model to disk.
source code

Inherited from utils.nltk.ngram.baumwelch.BaumWelchTrainer: __init__, train

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

Class Methods [hide private]

Inherited from utils.nltk.ngram.baumwelch.BaumWelchTrainer: process_option_dict

Static Methods [hide private]
 
sequence_updates(sequence, last_model, empty_arrays, array_ids, update_initial=True)
This should be overridden by subclasses, but not by defining a static method on the class, since the function must be picklable.
source code
Class Variables [hide private]
  OPTIONS = BaumWelchTrainer.OPTIONS+ [ModuleOption('initkey', f...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

record_history(self, line)

source code 

Stores a line in the history of the model to keep a record of training steps.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.record_history

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

source code 

This should be overridden by subclasses, but not by defining a static method on the class, since the function must be picklable. For this, it needs to be a top-level function. Then you can set the sequence_updates attribute to point to it (using staticmethod), as we have done in the default implementation.

Parameters:
  • update_initial (bool) - if update_initial=False, the initial state distribution updates won't be made for this sequence
Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.sequence_updates

create_mutable_model(self, model)

source code 

Creates a mutable version of the given model. This mutable version will be the model that receives updates during training, as defined by update_model.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.create_mutable_model
(inherited documentation)

get_empty_arrays(self)

source code 

Creates empty arrays to hold the accumulated probabilities during training. The sizes will depend on self.model.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.get_empty_arrays
(inherited documentation)

get_array_indices(self)

source code 

Returns a tuple of the dicts that map labels, emissions, etc to the indices of arrays to which they correspond. These will need to be different for non-standard models.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.get_array_indices
(inherited documentation)

sequence_updates_callback(self, result)

source code 

Callback for the sequence_updates processes that takes the updates from a single sequence and adds them onto the global update accumulators.

The accumulators are stored as self.global_arrays.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.sequence_updates_callback
(inherited documentation)

update_model(self, arrays, array_ids)

source code 

Replaces the distributions of the saved model with the probabilities taken from the arrays of updates. self.model is expected to be made up of mutable distributions when this is called.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.update_model

save(self)

source code 

Saves the model in self.model to disk. This may be called at the end of each iteration and will be called at the end of the whole training process.

By default, does nothing. You don't have to put something in here, but you'll need to override this if you want the model to be saved during training before it gets return at the end.

Overrides: utils.nltk.ngram.baumwelch.BaumWelchTrainer.save
(inherited documentation)

Class Variable Details [hide private]

OPTIONS

Value:
BaumWelchTrainer.OPTIONS+ [ModuleOption('initkey', filter= str_to_bool\
, help_text= "Train the initial key distribution. The default " "behav\
iour will leave the distribution alone (probably inited " "to uniform)\
: suitable if the training data is transposed into " "a common key. If\
 your data has keys, set to true", usage= "initkey=B, where B is 'true\
' or 'false' " "(default true)", default= False),]