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

心已赠人 2022-12-16 13:07 214阅读 0赞

用TensorFlow Lite转换模型时,报如下错误:

  1. Some of the operators in the model are not supported by the standard TensorFlow Lite
  2. runtime. If those are native TensorFlow operators, you might be able to use the extended
  3. runtime by passing --enable_select_tf_ops, or by setting
  4. target_ops=TFLITE_BUILTINS,SELECT_TF_OPS when calling tf.lite.TFLiteConverter().
  5. Otherwise, if you have a custom implementation for them you can disable this error with --
  6. allow_custom_ops, or by setting allow_custom_ops=True when calling
  7. tf.lite.TFLiteConverter(). Here is a list of builtin operators you are using: ADD,
  8. AVERAGE_POOL_2D, CAST, CONCATENATION, CONV_2D, DEPTHWISE_CONV_2D,
  9. FULLY_CONNECTED, GREATER_EQUAL, LESS, MUL, RESHAPE, SELECT,
  10. TRANSPOSE. Here is a list of operators for which you will need custom implementations:
  11. RandomUniform.

解决方法:

  1. import tensorflow as tf
  2. converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
  3. # 在convert()前加上这句
  4. converter.allow_custom_ops=True
  5. tflite_model = converter.convert()
  6. open("converted_model.tflite", "wb").write(tflite_model)

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

发表评论

表情:
评论列表 (有 0 条评论,214人围观)

还没有评论,来说两句吧...

相关阅读