我使用Google colab尝试将keras神经网络文件转换为tensorflow lite。
pip install --upgrade "tensorflow==1.7.*"
import tensorflow
from tensorflow.contrib import lite
#from tensorflow.contrib.lite.python import convert_saved_model
converter = lite.TFLiteConverter.from_keras_model_file( 'weights-origin.hdf5')
tfmodel = converter.convert()
open ("model.tflite" , "wb") .write(tfmodel)
我收到此消息:
AttributeError Traceback (most recent call last)
<ipython-input-4-b02b2298ffe4> in <module>()
----> 1 converter = lite.TFLiteConverter.from_keras_model_file( 'weights-origin.hdf5')
2 tfmodel = converter.convert()
3 #convert_saved_model.convert(saved_model_dir="/frozen_inference_graph.pb",output_tflite="/TF_Lite_Model")
4 open ("model.tflite" , "wb") .write(tfmodel)
AttributeError: module 'tensorflow.contrib.lite.python.lite' has no attribute 'TFLiteConverter'