tf.keras HDF5 模型和 Keras HDF5 模型

tf.keras HDF5 Model and Keras HDF5 Model

我想将 Keras 模型转换为 Tensorflow Lite 模型。当我查看文档时,说明我们可以使用 tf.keras HDF5 模型作为输入。这是否意味着我可以使用我保存的 HDF5 Keras 模型作为它的输入,或者 tf.keras HDF5 模型和 Keras HDF5 模型是不同的东西?

文档:https://www.tensorflow.org/lite/convert

编辑:我可以使用此 API 将我的 Keras 模型转换为 Tensorflow Lite 模型,但我尚未对其进行测试。我的代码:

converter = tf.lite.TFLiteConverter.from_keras_model_file(path + 'plant- 
recognition-model.h5')
tflite_model = converter.convert()

with open('plant-recognition-model.tflite', 'wb') as f:
   f.write(tflite_model)

tf.keras HDF5 模型和 Keras HDF5 模型没有什么不同,除了不可避免的软件版本更新同步性。 This is what the official docs say:

tf.keras is TensorFlow's implementation of the Keras API specification. This is a high-level API to build and train models that includes first-class support for TensorFlow-specific functionality

如果转换器可以将 keras 模型转换为 tf.lite,它将提供相同的结果。但是 tf.lite 功能比 tf.keras 更受限制。如果这个功能集对你来说还不够,你仍然可以使用 tensorflow,并享受它的其他优势。

也许,用不了多久你的模型就可以在智能手机上 运行。