Save an Estimator
Save an estimator (alongside its weights) to the directory export_dir_base
.
# S3 method for tf_estimator
export_savedmodel(object, export_dir_base,
serving_input_receiver_fn = NULL, assets_extra = NULL, as_text = FALSE,
checkpoint_path = NULL, overwrite = TRUE, versioned = !overwrite, ...)
Arguments
object | A TensorFlow estimator. |
export_dir_base | A string containing a directory in which to export the SavedModel. |
serving_input_receiver_fn | A function that takes no argument and
returns a |
assets_extra | A dict specifying how to populate the assets.extra
directory within the exported SavedModel, or |
as_text | whether to write the SavedModel proto in text format. |
checkpoint_path | The checkpoint path to export. If |
overwrite | Should the |
versioned | Should the model be exported under a versioned subdirectory? |
... | Optional arguments passed on to the estimator's
|
Value
The path to the exported directory, as a string.
Details
This method builds a new graph by first calling the serving_input_receiver_fn
to obtain feature Tensor
s, and then calling this Estimator
's model_fn to
generate the model graph based on those features. It restores the given
checkpoint (or, lacking that, the most recent checkpoint) into this graph in
a fresh session. Finally it creates a timestamped export directory below the
given export_dir_base, and writes a SavedModel
into it containing a single
MetaGraphDef
saved from this session. The exported MetaGraphDef
will
provide one SignatureDef
for each element of the export_outputs dict
returned from the model_fn, named using the same keys. One of these keys is
always signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY, indicating
which signature will be served when a serving request does not specify one.
For each signature, the outputs are provided by the corresponding
ExportOutput
s, and the inputs are always the input receivers provided by
the serving_input_receiver_fn. Extra assets may be written into the
SavedModel via the extra_assets argument. This should be a dict, where each
key gives a destination path (including the filename) relative to the
assets.extra directory. The corresponding value gives the full path of the
source file to be copied. For example, the simple case of copying a single
file without renaming it is specified as {'my_asset_file.txt': '/path/to/my_asset_file.txt'}
.
Raises
ValueError: if no serving_input_receiver_fn is provided, no export_outputs are provided, or no checkpoint can be found.
See also
Other custom estimator methods: estimator_spec
,
estimator
,
evaluate.tf_estimator
,
predict.tf_estimator
,
train.tf_estimator