tfma.exporter.LatestExporter

Class LatestExporter

This class regularly exports the EvalSavedModel.

In addition to exporting, this class also garbage collects stale exports.

__init__

__init__(
    name,
    eval_input_receiver_fn,
    exports_to_keep=5
)

Create an Exporter to use with tf.estimator.EvalSpec.

Args:

  • name: Unique name of this Exporter that is going to be used in the export path.
  • eval_input_receiver_fn: Eval input receiver function.
  • exports_to_keep: Number of exports to keep. Older exports will be garbage-collected. Defaults to 5. Set to None to disable garbage collection.

Raises:

  • ValueError: if exports_to_keep is set to a non-positive value.

Properties

name

Directory name.

A directory name under the export base directory where exports of this type are written. Should not be None nor empty.

Methods

export

export(
    estimator,
    export_path,
    checkpoint_path,
    eval_result,
    is_the_final_export
)

Exports the given Estimator to a specific format.

Args:

  • estimator: the Estimator to export.
  • export_path: A string containing a directory where to write the export.
  • checkpoint_path: The checkpoint path to export.
  • eval_result: The output of Estimator.evaluate on this checkpoint.
  • is_the_final_export: This boolean is True when this is an export in the end of training. It is False for the intermediate exports during the training. When passing Exporter to tf.estimator.train_and_evaluate is_the_final_export is always False if TrainSpec.max_steps is None.

Returns:

The string path to the exported directory or None if export is skipped.