Export to Saved Model format

model_to_saved_model(
  model,
  saved_model_path,
  custom_objects = NULL,
  as_text = FALSE,
  input_signature = NULL,
  serving_only = FALSE
)

Arguments

model

A Keras model to be saved. If the model is subclassed, the flag serving_only must be set to TRUE.

saved_model_path

a string specifying the path to the SavedModel directory.

custom_objects

Optional dictionary mapping string names to custom classes or functions (e.g. custom loss functions).

as_text

bool, FALSE by default. Whether to write the SavedModel proto in text format. Currently unavailable in serving-only mode.

input_signature

A possibly nested sequence of tf.TensorSpec objects, used to specify the expected model inputs. See tf.function for more details.

serving_only

bool, FALSE by default. When this is true, only the prediction graph is saved.

Value

Invisibly returns the saved_model_path.

Note

This functionality is experimental and only works with TensorFlow version >= "2.0".

See also

Other saved_model: model_from_saved_model()