【问题标题】:TfLite for Microcontrollers giving hybrid error用于微控制器的 TfLite 给出混合错误
【发布时间】:2020-06-27 13:02:47
【问题描述】:

为了在新的 OpenMV Cam H7 plus 上运行,我将我的 keras .h5 文件转换为量化的 tflite,但是当我运行它时,我收到一条错误消息,提示“TFLite Micro 不支持混合模型。”

我不确定为什么我的模型显示为混合模型;我用来转换的代码如下:

model = load_model('inceptionV3.h5')

# Convert the model.
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
tflite_model = converter.convert()

# Save the TF Lite model.
with tf.io.gfile.GFile('inceptionV3_openmv2.tflite', 'wb') as f:
  f.write(tflite_model)

如果我做错了什么或有更好的方法来转换它,如果有人能指导我,我将不胜感激。

【问题讨论】:

    标签: tensorflow tensorflow2.0 tensorflow-lite


    【解决方案1】:

    试试这个代码

    import tensorflow as tf
    converter = tf.lite.TFLiteConverter.from_keras_model_file("inceptionV3.h5")
    converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
    converter.target_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
    tf_model = converter.convert() 
    open ("inceptionV3_openmv2.tflite" , "wb") .write(tf_model)
    

    【讨论】:

    猜你喜欢
    • 2020-07-01
    • 2017-01-11
    • 1970-01-01
    • 1970-01-01
    • 2022-07-17
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多