log_model

function wandb.log_model

wandb.log_model(
    path: 'StrPath',
    name: 'str | None' = None,
    aliases: 'list[str] | None' = None
)  None

Logs a model artifact containing the contents inside the path to a run and marks it as an output to this run.

Args:

  • path: A path to the contents of this model, can be in the following forms
    • /local/directory
    • /local/directory/file.txt
    • s3://bucket/path
  • name: A name to assign to the model artifact that the file contents will be added to. The string must contain only alphanumeric characters such as dashes, underscores, and dots. This will default to the basename of the path prepended with the current run id if not specified.
  • aliases: Aliases to apply to the created model artifact, defaults to ["latest"]

Returns: None

Raises:

  • ValueError: if name has invalid special characters

Examples:

run.log_model(
   path="/local/directory",
   name="my_model_artifact",
   aliases=["production"],
)

Invalid usage

run.log_model(
    path="/local/directory",
    name="my_entity/my_project/my_model_artifact",
    aliases=["production"],
)