Example: Prepare a TensorFlow Model for Deployments
Train and output a Tensorflow Model
Example with TensorFlow
# Set export dir
export_dir = os.path.abspath(os.environ.get('PS_MODEL_PATH', os.getcwd() + '/models'))
# Define Model
mnist_classifier = tf.estimator.Estimator(
model_fn=model_function,
model_dir=flags_obj.model_dir,
config=run_config,
params={
'data_format': data_format,
})
image = tf.placeholder(tf.float32, [None, 28, 28])
# Define Input
input_fn = tf.estimator.export.build_raw_serving_input_receiver_fn({
'image': image,
})
# Export Model using builtin tensorflow export_savedmodel
mnist_classifier.export_savedmodel(flags_obj.export_dir, input_fn,
strip_default_attrs=True)
tf.logging.debug('Model Exported')
SavedModel format
Last updated