让Tensorflow2.0运行Tensorflow1.x的代码

tensorflow2.0运行1.0的代码会报错误:

“AttributeError: module ‘tensorflow’ has no attribute ‘placeholder’”

解决方案:

import tensorflow.compat.v1    as     tf 
tf.disable_eager_execution()  #关闭eager运算
发布了8 篇原创文章 · 获赞 4 · 访问量 1489

猜你喜欢

转载自blog.csdn.net/qq_36229876/article/details/104061981