Skip to content
Advertisement

Save TensorFlowJS MobileNet + KNN to TFLite

I have trained a KNN on top of MobileNet logits results using TensorFlowJS.

And I want to know how can I export the result of the MobileNet + KNN to a TFLite model.

JavaScript

Advertisement

Answer

1. Save the model

Save the model this example saves the file to the native file system or if you need it to be saved in other places then check the documentation.

JavaScript

You should have a JSON file and a binary weight file(s) after this step.

2. Convert from TensorFlow.js Layers model to Saved Model format

tfjs_model.json is the path to the model.json that you get from the previous step and saved_model is the path where you want to save the SavedModel format.
You can read more about using the TensorflowJS Converter from here.

JavaScript

3. Convert from SavedModel format to TFLite format

Converting from a SavedModel format to TFLite is the recommended way to do this as per the documentation.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement