tf.lite.TFLiteConverter

View source on GitHub

Converts a TensorFlow model into TensorFlow Lite model.

tf.lite.TFLiteConverter(
    funcs, trackable_obj=None
)

Args:

Attributes:

Example usage:

# Converting a SavedModel to a TensorFlow Lite model.
converter = lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()

# Converting a tf.Keras model to a TensorFlow Lite model.
converter = lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()

# Converting ConcreteFunctions to a TensorFlow Lite model.
converter = lite.TFLiteConverter.from_concrete_functions([func])
tflite_model = converter.convert()

Methods

convert

View source

convert()

Converts a TensorFlow GraphDef based on instance variables.

Returns:

The converted data in serialized format.

Raises:

from_concrete_functions

View source

@classmethod
from_concrete_functions(
    funcs
)

Creates a TFLiteConverter object from ConcreteFunctions.

Args:

Returns:

TFLiteConverter object.

Raises:

Invalid input type.

from_keras_model

View source

@classmethod
from_keras_model(
    model
)

Creates a TFLiteConverter object from a Keras model.

Args:

Returns:

TFLiteConverter object.

from_saved_model

View source

@classmethod
from_saved_model(
    saved_model_dir, signature_keys=None, tags=None
)

Creates a TFLiteConverter object from a SavedModel directory.

Args:

Returns:

TFLiteConverter object.

Raises:

Invalid signature keys.