tensorflow2和1的一些区别


AttributeError: module 'tensorflow' has no attribute 'placeholder'

原因是在tf2的版本下使用了1的API

改正方法:

import tensorflow.compat.v1 as tf

tf.disable_v2_behavior()

替换 import tensorflow as tf

X = tf.compat.v1.placeholder()

替换X = placeholder()

 

"AttributeError: module 'tensorflow' has no attribute 'random_normal'"

 

最新一版的random_normal方法已经换为:random.normal

直接在代码段中修改即可。

 


免责声明!

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



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