Checkpointer

Classes:

Checkpointer(checkpoint_dir, …[, …])

Class for saving a models checkpoints, weight files and embeddings.

class check_pointer.Checkpointer(checkpoint_dir, experiment_name, model, save_ckpt=False, save_weights=False, keep_best=1, minimise=True)

Bases: object

Class for saving a models checkpoints, weight files and embeddings.

Methods:

get_best()

Returns the key (step) with the best monitored metric from the current training session.

get_best_ckpt()

Returns the file name of the best checkpoint from the current training session, if it exists.

get_best_weights()

Returns the file name of the best weights from the current training session, if it exists.

save(step)

Creates a new checkpoint and/or weight file for the model at the current step.

save_best(metric_val, step)

Creates a new checkpoint/weights file if the current metric value is better than the least best.

save_embeddings(output_dir, vocabulary[, …])

Creates a word embedding .txt file from the models embedding layer.

get_best()

Returns the key (step) with the best monitored metric from the current training session.

get_best_ckpt()

Returns the file name of the best checkpoint from the current training session, if it exists.

get_best_weights()

Returns the file name of the best weights from the current training session, if it exists.

save(step)

Creates a new checkpoint and/or weight file for the model at the current step.

Parameters

step (int) – The current global step of the training model, used for creating file names

save_best(metric_val, step)

Creates a new checkpoint/weights file if the current metric value is better than the least best.

Keeps the number according to keep_best value.

Parameters
  • metric_val (float) – The current metric value to compare

  • step (int) – The current global step of the training model, used for creating file names

save_embeddings(output_dir, vocabulary, layer_name='embedding')

Creates a word embedding .txt file from the models embedding layer.

Parameters
  • output_dir (str) – Location to save the embedding file

  • vocabulary (Gluonnlp Vocab) – Data sets vocabulary for mapping indexes to words

  • layer_name (str) – Name of the embedding layer, default = ‘embedding’