Home > database >  module 'tensorflow._api.v2.lite' has no attribute 'TFliteConverter'
module 'tensorflow._api.v2.lite' has no attribute 'TFliteConverter'

Time:12-09

I am trying to convert a tensorflow model to tensorflowlite model

converter =tf.lite.TFliteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_model = converter.convert()
open(tflite_model_name   '.tflite', 'wb').write(tflite_model)

But I get the error "module 'tensorflow._api.v2.lite' has no attribute 'TFliteConverter' " Is it because I use LSTM in my model?

CodePudding user response:

You have a typo on your code. converter = tf.lite.TFLiteConverter.from_keras_model(model) instead of converter =tf.lite.TFliteConverter.from_keras_model(model)

CodePudding user response:

Thanks. I get this error now.

ConverterError: /usr/local/lib/python3.7/dist- 
packages/tensorflow/python/saved_model/save.py:1315:0: error: 
'tf.TensorListReserve' op requires element_shape to be static during TF Lite 
transformation pas
  • Related