美文网首页
tf.saved_model.load用于载入saved_mod

tf.saved_model.load用于载入saved_mod

作者: LabVIEW_Python | 来源:发表于2021-06-13 19:00 被阅读0次

TensorFlow 2.x 的SavedModel 文件包含一个完整的 TensorFlow 模型——不仅包含权重值,还包含模型的构架和计算。它不需要原始模型构建代码就可以运行,因此,非常有利于模型的共享和部署

使用 tf.saved_model.load 将 SavedModel 重新加载到 Python 中

可以用TensorFlow自带的 SavedModel 命令行界面 (CLI) 查看SavedModel模型,例如

saved_model_cli show --dir /tmp/saved_model_dir --all
saved_model_cli show --dir /tmp/saved_model_dir --all

tf.saved_model.load()的返回值是:
Returns:
A trackable object with a signatures attribute mapping from signature
keys to functions. If the SavedModel was exported by tf.saved_model.save,
it also points to trackable objects, functions, debug info which it has been
saved.
使用范例
Signatures associated with the SavedModel are available as functions:

imported = tf.saved_model.load(path)
f = imported.signatures["serving_default"]
print(f(x=tf.constant([[1.]])))

心得:开源软件的API帮助信息写的很糟糕,必须直接看源码

相关文章

网友评论

      本文标题:tf.saved_model.load用于载入saved_mod

      本文链接:https://www.haomeiwen.com/subject/znegeltx.html