![]() |
Regularly exports registered modules into timestamped directories.
hub.LatestModuleExporter(
name, serving_input_fn, exports_to_keep=5
)
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(
input_fn=eval_input_fn,
exporters=[
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.
THIS FUNCTION IS DEPRECATED.
Args | |
---|---|
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. |
Raises | |
---|---|
ValueError
|
if any argument is invalid. |
Attributes | |
---|---|
name
|
Directory name.
A directory name under the export base directory where exports of
this type are written. Should not be |
Methods
export
export(
estimator,
export_path,
checkpoint_path=None,
eval_result=None,
is_the_final_export=None
)
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())
Args | |
---|---|
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. |
Returns | |
---|---|
The path to the created timestamped directory containing the exported modules. |