TensorFlow2报错:tf.placeholder() is not compatible with eager execution.


 

当我们将TensorFlow1.x中的程序迁移到2.0+版本时,在之前1.x版本中有函数tf.placeholder(),替换成tf.compat.v1.placeholder(),运行时报如下错误:

tf.placeholder() is not compatible with eager execution.

 

解决方案:

在代码前加入下面一行即可:

tf.compat.v1.disable_eager_execution()

 

更多请参见博文:

https://blog.csdn.net/caoyuan666/article/details/104706756   

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM