Test accuracy for model.tflite

Recently i do training with tensorflow and then convert it to tensorflow lite model
This is how i convert the model

Convert model.

converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()

save model.

with open(‘C:/Users/MobileNetV2_2/model52/model.tflite’, ‘wb’) as f:


How can i know the accuracy from tflite model, i already try
model.evaluate_tflite(“model.tflite”, test_dataset)

But it got error, the error is
AttributeError: ‘Functional’ object has no attribute ‘evaluate_tflite’

Apparently, by the code snippet, the model variable was not created by Model Maker, right? It seems you converted a model using the TFLite converter

the method evaluate_tflite is specific to Model Makers model class and it’s not a regular TFLite method.

you can see the code here

As you can see, it’s specific per problem domain. You can follow the code to implement your own version if needed.

So it’s impossible for my issue to test the accuration of tflite model? and i have to use tflite model maker instead?

No, it’s not impossible and
No, you don’t need to use Model maker

The issue is that the method you are trying to use is not present on the TFLite model class.

You can test your tflite model’s accuracy, but you might need to copy that method from Model Maker source code and make it specific for your use case.
For example, for object detection, you can see some code here

In essence what this method does is use the model to do inference over your dataset and calculate how far it is from the target results using some specific metric.