pystruct.utils.SaveLogger

class pystruct.utils.SaveLogger(file_name, save_every=10, verbose=0)[source]

Logging class that stores the model periodically.

Can be used to back up a model during learning. Also a prototype to demonstrate the logging interface.

Parameters:

file_name : string

File in which the model will be stored. If the string contains ‘%d’, this will be replaced with the current iteration.

save_every : int (default=10)

How often the model should be stored (in iterations).

verbose : int (default=0)

Verbosity level.

Methods

load() Load the model stoed in file_name and return it.
save(learner, file_name) Save the model to location specified in file_name.
__init__(file_name, save_every=10, verbose=0)[source]
__call__(learner, iteration=0)[source]

Save learner if iterations is a multiple of save_every or “final”.

Parameters:

learner : object

Learning object to be saved.

iteration : int or ‘final’ (default=0)

If ‘final’ or save_every % iteration == 0, the model will be saved.

load()[source]

Load the model stoed in file_name and return it.

save(learner, file_name)[source]

Save the model to location specified in file_name.