Skip to content

Instantly share code, notes, and snippets.

@wronk
Created February 13, 2019 19:33
Show Gist options
  • Save wronk/01fba42026b336d2400c501f13bc68ed to your computer and use it in GitHub Desktop.
Save wronk/01fba42026b336d2400c501f13bc68ed to your computer and use it in GitHub Desktop.
TF Serving blog post: creating and saving TF estimator object
# Define a place to save your compiled model
export_dir = '/path/to/my_exported_models/001'
# Define a path to your trained keras model and load it in as a `tf.keras.models.Model`
# If you just trained your model, you may already have it in memory and can skip the below 2 lines
model_save_fpath = '/path/to/my_model.h5'
keras_model = tf.keras.models.load_model(model_save_fpath)
# Create an Estimator object
estimator_save_dir = '/path/to/save/estimator'
estimator = tf.keras.estimator.model_to_estimator(keras_model=keras_model,
model_dir=estimator_save_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment