Save the date! Google I/O returns May 18-20 Register now


View source on GitHub

Updates the method name(s) of the SavedModel stored in the given path.

The MethodNameUpdater class provides the functionality to update the method name field in the signature_defs of the given SavedModel. For example, it can be used to replace the predict method_name to regress.

Typical usages of the MethodNameUpdater

updater = tf.compat.v1.saved_model.MethodNameUpdater(export_dir)
# Update all signature_defs with key "foo" in all meta graph defs.
updater.replace_method_name(signature_key="foo", method_name="regress")
# Update a single signature_def with key "bar" in the meta graph def with
# tags ["serve"]
updater.replace_method_name(signature_key="bar", method_name="classify",

export_dir Directory containing the SavedModel files.

IOError If the saved model file does not exist, or cannot be successfully parsed.



View source

Replaces the method_name in the specified signature_def.

This will match and replace multiple sig defs iff tags is None (i.e when multiple MetaGraphs have a signature_def with the same key). If tags is not None, this will only replace a single signature_def in the MetaGraph with matching tags.

signature_key Key of the signature_def to be updated.
method_name new method_name to replace the existing one.
tags A tag or sequence of tags identifying the MetaGraph to update. If None, all meta graphs will be updated.

ValueError if signature_key or method_name are not defined or if no metagraphs were found with the associated tags or if no meta graph has a signature_def that matches signature_key.


View source

Saves the updated SavedModel.

new_export_dir Path where the updated SavedModel will be saved. If None, the input SavedModel will be overriden with the updates.

errors.OpError If there are errors during the file save operation.