Some of the operators in the model are not supported by the standard TensorFlow Lite runtime. If th

问题

Some of the operators in the model are not supported by the standard TensorFlow Lite runtime. 
If those are native TensorFlow operators, 
you might be able to use the extended runtime by passing --enable_select_tf_ops, 
or by setting target_ops=TFLITE_BUILTINS,SELECT_TF_OPS when calling tf.lite.TFLiteConverter(). 
Otherwise, if you have a custom implementation for them you can disable this error with --allow_custom_ops, 
or by setting allow_custom_ops=True when calling tf.lite.TFLiteConverter(). 
Here is a list of builtin operators you are using: ADD, ADD_N, CAST, CONCATENATION, CONV_2D, FLOOR, FULLY_CONNECTED, GATHER_ND, LOGISTIC, MAXIMUM, MINIMUM, MUL, PACK, RESHAPE, RESIZE_NEAREST_NEIGHBOR, STRIDED_SLICE, SUB. 
Here is a list of operators for which you will need custom implementations: ROUND.

解决方法

  • 官方方法
    官网链接:https://www.tensorflow.org/lite/guide/ops_select
import tensorflow as tf

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
# 加上这句
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
                                       tf.lite.OpsSet.SELECT_TF_OPS]
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

  • 本次解决方法
import tensorflow as tf

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
# 加上这句
converter.allow_custom_ops=True

tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

你可能感兴趣的:(解决方案,TensorFlow)