[英]Tensorflow quantization on Windows
我已經凍結了模型並獲得了.pb文件。 然后,我在Linux上使用tocoConverter量化了我的模型,因為Windows不支持它。 我有quantized_model.tflite。 我可以加載它並在Linux上獲得預測,但是根據我的項目需要,在Windows上安裝它存在一些問題。 我嘗試使用tf.contrib.lite.Interpreter使用以下代碼加載它:
import numpy as np
import tensorflow as tf
# Load TFLite model and allocate tensors.
interpreter=tf.contrib.lite.Interpreter(model_path="quantized_model.tflite")
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test model on random input data.
input_shape = input_details[0]['shape']
# change the following line to feed into your own data.
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'],input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
*ImportError: No module named 'tensorflow.contrib.lite.python.Interpreter*
但是它失敗,並出現“沒有名為'tensorflow.contrib.lite.python.interpreter的模塊”錯誤。 嘗試使用tf.contrib.lite中的某些內容時,在Windows上總是會出現此錯誤。 也許有一種方法可以在Windows上加載它? 還是可以建議其他選擇來量化Windows上的模型?
Windows build for cmake當前不支持toco。 這是我記得在某處閱讀的內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.