Punya pertanyaan? Terhubung dengan komunitas di Forum Kunjungan TensorFlow Forum


Regularly exports registered modules into timestamped directories.

Modules can be registered to be exported by this class by calling register_module_for_export when constructing the graph. The export_name provided determines the subdirectory name used when exporting.

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

Example use with EvalSpec:

  train_spec = tf.estimator.TrainSpec(...)
  eval_spec = tf.estimator.EvalSpec(
          hub.LatestModuleExporter("tf_hub", serving_input_fn),
  tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)

See LatestModuleExporter.export() for a direct use example.


name unique name of this Exporter, which will be used in the export path.
serving_input_fn A function with no arguments that returns a ServingInputReceiver. This is used with the estimator passed to export() to build the graph (in PREDICT mode) that registers the modules for export. The model in that graph is never run, so the actual data provided by this input fn does not matter.
exports_to_keep Number of exports to keep. Older exports will be garbage collected. Defaults to 5. Set to None to disable garbage collection.

ValueError if any argument is invalid.

name Directory name.

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



View source

Actually performs the export of registered Modules.

This method creates a timestamped directory under export_path with one sub-directory (named export_name) per module registered via register_module_for_export.

Example use:

  estimator = ... (Create estimator with modules registered for export)...
  exporter = hub.LatestModuleExporter("tf_hub", serving_input_fn)
  exporter.export(estimator, export_path, estimator.latest_checkpoint())

estimator the Estimator from which to export modules.
export_path A string containing a directory where to write the export timestamped directories.
checkpoint_path The checkpoint path to export. If None, estimator.latest_checkpoint() is used.
eval_result Unused.
is_the_final_export Unused.

The path to the created timestamped directory containing the exported modules.