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