rxn.onmt_models.training_files.ModelFiles

class rxn.onmt_models.training_files.ModelFiles(model_dir)[source]

Bases: object

Class to make it easy to get the names/paths of the trained OpenNMT models.

Parameters

model_dir (Union[str, PathLike]) –

__init__(model_dir)[source]
Parameters

model_dir (Union[str, PathLike]) –

Methods

__init__(model_dir)

param model_dir

get_checkpoints()

Get the checkpoints contained in the directory, sorted by step number.

get_last_checkpoint()

Get the last checkpoint matching the naming including the step number.

next_config_file()

Get the next available config file name.

Attributes

MODEL_PREFIX

MODEL_STEP_PATTERN

ONMT_CONFIG_FILE

model_prefix

Absolute path to the model prefix; during training, OpenNMT will append "_step_10000.pt" to it (or other step numbers).

get_checkpoints()[source]

Get the checkpoints contained in the directory, sorted by step number.

Return type

List[Path]

get_last_checkpoint()[source]

Get the last checkpoint matching the naming including the step number.

Raises

RuntimeError – no model is found in the expected directory.

Return type

Path

property model_prefix: Path

Absolute path to the model prefix; during training, OpenNMT will append “_step_10000.pt” to it (or other step numbers).

Return type

Path

next_config_file()[source]

Get the next available config file name.

Return type

Path