问题描述
我已经使用Google Cloud Platform的AutoML功能来训练机器学习(表)模型。训练完成后,我将模型导出到本地计算机。导出的文件结构如下:
model
- assets
- assets.extra
- saved_model.pb
- variables
我的目标是能够将模型用于Web应用程序。我尝试了两种主要方法,但都失败了。
第一种方法是使用Tensorflow的 tf.keras.models.load_model('model_file') 符合Tensorflow 2.3.0的功能 这将返回错误:
tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'DecodeProtoSparseV2' in binary running on Joshuas-Air.lan. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib,accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph,as contrib ops are lazily registered when the module is first accessed.
为了解决此问题,一些(https://github.com/tensorflow/hub/issues/463)建议添加
import tensorflow_text
到python脚本。但是,这只是产生了错误:
tensorflow.python.framework.errors_impl.NotFoundError: Converting GraphDef to Graph has failed. The binary trying to import the GraphDef was built when GraphDef version was 440. The GraphDef was produced by a binary built when GraphDef version was 470. The difference between these versions is larger than TensorFlow's forward compatibility guarantee. The following error might be due to the binary trying to import the GraphDef being too old.
尝试修补每个后续错误会打开新错误,并导致令人沮丧的兔子洞。我已经研究过通过http API(使用Docker / Tensorflow服务)使用该模型,但是这很复杂,我需要将模型存储在代码中以满足速度要求。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)