tf.keras HDF5 Model and Keras HDF5 Model

耗尽温柔 提交于 2020-07-22 10:11:50

问题


I want to convert a Keras model to Tensorflow Lite model. When I examined the documentation, it is stated that we can use tf.keras HDF5 models as input. Does it mean I can use my saved HDF5 Keras model as input to it or tf.keras HDF5 model and Keras HDF5 models are different things?

Documentation: https://www.tensorflow.org/lite/convert

Edit: I could convert my Keras model to Tensorflow Lite model with using this API, but I didn't test it yet. My code:

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)

回答1:


tf.keras HDF5 model and Keras HDF5 models are not different things, except for inevitable software version update synchronicity. 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

If the convertor can convert a keras model to tf.lite, it will deliver same results. But tf.lite functionality is more limited than tf.keras. If this feature set is not enough for you, you can still work with tensorflow, and enjoy its other advantages.

May be, it won't take too long before your models can run on a smartphone.



来源:https://stackoverflow.com/questions/55964427/tf-keras-hdf5-model-and-keras-hdf5-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!