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

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

 

posted @ 2020-12-02 11:05  转角102  阅读(1761)  评论(0编辑  收藏  举报