【tensorflow】How to fix this module 'tensorflow' has no attribute 'lite'?

converter =  tf.lite.TocoConverter.from_keras_model_file("model2.h5")
tflite_quantized_model=converter.convert()
open("quantized_model.tflite", "wb").write(tflite_quantized_model)

找不到lite,所以tensorflow-gpu=1.8 不行啦

升级到1.13.cudu和cudnn不行

降级到1.12,如下的方案:

https://stackoverflow.com/questions/53914785/how-to-fix-this-module-tensorflow-has-no-attribute-lite

converter = tf.contrib.lite.TFLiteConverter.from_keras_model_file("sample_android.h5")

tflite_model = converter.convert()

open("quantized_model.tflite", "wb").write(tflite_quantized_model)

 

https://stackoverflow.com/questions/53680660/attributeerror-module-tensorflow-has-no-attribute-lite-in-keras-model-to-te

In tensorflow 1.12 it should be converter = tf.contrib.lite.TFLiteConverter.from_keras_model_file(keras_file)

还是不行。

果断用tensorflow算啦。

 

import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_keras_model_file("live_dete_generator_validation_data.h5")
# converter = tf.contrib.lite.TFLiteConverter.from_keras_model_file("live_dete_generator_validation_data.h5")
tflite_quantized_model= converter.convert()
open("quantized_model.tflite", "wb").write(tflite_quantized_model)

 

还是不行啦。。。。

你可能感兴趣的:(Tensorflow)