Tensorflow Serving 部署自己的模型时遇到如下报错:
module ‘tensorflow’ has no attribute ‘reset_default_graph’
解决方案如下:
1,原本的代码
import tensorflow as tf #这行代码改成下面的两行代码
2,替换成如下代码:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
运行成功。
Reference
linkTensorFlow学习记录:用TensorFlow_Serving部署模型并进行远程使用
link module ‘tensorflow’ has no attribute ‘reset_default_graph’
在尝试使用TensorFlow Serving部署自定义模型时遇到了'module 'tensorflow' has no attribute 'reset_default_graph''的问题。通过将导入tensorflow的方式改为import tensorflow.compat.v1 as tf,并启用tf.disable_v2_behavior(),成功解决了该错误,使得模型部署得以正常运行。这个解决方案对于从TensorFlow 1.x升级到2.x的开发者尤其有用。

1万+

被折叠的 条评论
为什么被折叠?



