Converting to TensorFlow Lite

From
Revision as of 03:45, 27 June 2019 by BPeat (talk | contribs)
Jump to: navigation, search

Youtube search... ...Google search

TensorFlow Lite converter: lite.TFLiteConverter

The TensorFlow Lite converter is used to convert TensorFlow models; GraphDef or SavedModel into an optimized FlatBuffer format, so that they can be used by the TensorFlow Lite interpreter or graph visualization.

  1. Converting a GraphDef from session.

converter = lite.TFLiteConverter.from_session(sess, in_tensors, out_tensors) tflite_model = converter.convert() open("converted_model.tflite", "wb").write(tflite_model)

  1. Converting a GraphDef from file.

converter = lite.TFLiteConverter.from_frozen_graph(

 graph_def_file, input_arrays, output_arrays)

tflite_model = converter.convert() open("converted_model.tflite", "wb").write(tflite_model)

  1. Converting a SavedModel.

converter = lite.TFLiteConverter.from_saved_model(saved_model_dir) tflite_model = converter.convert()

  1. Converting a tf.keras model.

converter = lite.TFLiteConverter.from_keras_model_file(keras_model) tflite_model = converter.convert()

TocoConverter (THIS FUNCTION IS DEPRECATED)