"AttributeError: module 'tensorflow' has no attribute 'random_normal'"问题解决办法

报错:
AttributeError: module 'tensorflow' has no attribute 'random_normal'

在这里插入图片描述

原因:

我使用的是tf2,最新一版的random_normal方法已经换为:random.normal

解决办法

1、直接代码段中进行修改即可
2、使用

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

替换

import tensorflow as tf

第二种方法可解决大多数AttributeError: module 'tensorflow' has no attribute问题

发布了29 篇原创文章 · 获赞 10 · 访问量 3182

猜你喜欢

转载自blog.csdn.net/sinat_40875078/article/details/105499610