【发布时间】:2021-04-23 01:46:51
【问题描述】:
我必须尝试对我的模型(tflite)进行量化。
我想通过动态范围量化将float32改为float 16。
这是我的代码:
import tensorflow as tf
import json
import sys
import pprint
from tensorflow import keras
import numpy as np
converter = tf.lite.TFLiteConverter.from_saved_model('models')
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_types = [tf.float16]
tflite_quant_model = converter.convert()
open("quant.tflite", "wb").write(tflite_quant_model)
在我的 MacBook 中,有一个名为“models”的文件夹,其中包含两个 tflite 文件。
当我执行代码时,出现以下错误:
converter = tf.lite.TFLiteConverter.from_saved_model('quantization')
OSError: SavedModel file does not exist at: models/{saved_model.pbtxt|saved_model.pb}
我检查了堆栈溢出中的大部分帖子,但找不到解决方案。
请检查我的代码并给我一些建议。
我上传了我的 tflite 文件,因为我想有必要检查是否有问题。
这是我的模型(下载链接):
https://drive.google.com/file/d/13gft7bREsv2vZYFvfoCiP5ndxHkfGKIM/view?usp=sharing
非常感谢。
【问题讨论】: