tensorflow: Problem converting from saved model to tflite model
Hi, I’m trying to convert my model (saved in ‘saved model’ format) to a tflite model but I get an error, this is my code:
`converter = tf.lite.TFLiteConverter.from_saved_model(‘saved_model’) tflite_model = converter.convert()
with open(‘model.tflite’, ‘wb’) as f: f.write(tflite_model)`
The error is this: loc(fused[“ReadVariableOp:”, “sequential_1/conv2d_1/ReadVariableOp@__inference_serving_default_285”]): error: missing attribute ‘value’ LLVM ERROR: Failed to infer result type(s).
I read the tensorflow page related to the topic and it explains that a refactoring of my model is probably necessary, so I tried to follow the indication but the error I get is the same (my other code is this:)
` import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model(‘saved_model’) converter.target_spec.supported_ops = [ tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops. tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops. ] tflite_model = converter.convert() open(“converted_model.tflite”, “wb”).write(tflite_model) ` I hope someone is able to help me, thanks in advance
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (3 by maintainers)
Just in case it helps others like me struggling with this issue. I realized I was using TensorFlow 2.16.1 , from docker image tensorflow:latest-gpu and that was the source of the problem. I switched to docker image tensorflow:2.15.0-gpu and the problem went away, all working fine now.
Same issue here. 2.16.1 crashed, 2.15 worked.
@adamantivm Thanks for helping with my project, good idea! Solved this problem.