opennmt.config module

Defines functions related to configuration files.

opennmt.config.load_model_module(path)[source]

Loads a model configuration file.

Parameters:path – The relative path to the configuration file.
Returns:A Python module.
opennmt.config.load_model_from_file(path)[source]

Loads a model from a configuration file.

Parameters:path – The relative path to the configuration file.
Returns:A opennmt.models.model.Model instance.
opennmt.config.load_model_from_catalog(name)[source]

Loads a model from the catalog.

Parameters:name – The model name.
Returns:A opennmt.models.model.Model instance.
opennmt.config.load_model(model_dir, model_file=None, model_name=None, serialize_model=True)[source]

Loads the model from the catalog or a file.

The model object is pickled in model_dir to make the model configuration optional for future runs.

Parameters:
  • model_dir – The model directory.
  • model_file – An optional model configuration. Mutually exclusive with model_name.
  • model_name – An optional model name from the catalog. Mutually exclusive with model_file.
  • serialize_model – Serialize the model definition in the model directory.
Returns:

A opennmt.models.model.Model instance.

Raises:

ValueError – if both model_file and model_name are set.

opennmt.config.load_config(config_paths, config=None)[source]

Loads configuration files.

Parameters:
  • config_paths – A list of configuration files.
  • config – A (possibly non empty) config dictionary to fill.
Returns:

The configuration dictionary.