【发布时间】:2020-05-04 15:32:35
【问题描述】:
我正在尝试将加载了 hub.load 的模型转换为 TFLite。 有问题的模型是universal-sentence-encoder (4),位于https://tfhub.dev/google/universal-sentence-encoder/4 我尝试在 Python 中使用 Tensorflow 版本 2.1.0 和 2.2.0
import tensorflow as tf
import tensorflow_hub as hub
model = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")
converter = tf.lite.TFLiteConverter.from_keras_model(model )
converter.experimental_new_converter = True // tried with and without
tflite_model = converter.convert()
我收到以下错误:
converter = tf.lite.TFLiteConverter.from_keras_model(model)
File "...\lib\site-packages\tensorflow_core\lite\python\lite.py", line 394, in from_keras_model
if not isinstance(model.call, _def_function.Function):
AttributeError: '_UserObject' object has no attribute 'call'
据我了解 hub.load 返回一个 keras SavedModel,所以不应该立即转换?
【问题讨论】:
标签: python tensorflow keras tensorflow-lite