load_model
- opennmt.load_model(model_dir, model_file=None, model_name=None, serialize_model=True, as_builder=False)[source]
Loads the model from the catalog or a definition file.
- 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 to make it optional for future runs.
as_builder – If
True
, return a callable building the model on call.
- Returns
A
opennmt.models.Model
instance or a callable returning such instance.- Raises
ValueError – if both
model_file
andmodel_name
are set.