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

我会带着你远行 2023-07-25 09:11 133阅读 0赞
报错:
  1. AttributeError: module 'tensorflow' has no attribute 'random_normal'

在这里插入图片描述

原因:

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

解决办法

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

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

替换

  1. import tensorflow as tf

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

发表评论

表情:
评论列表 (有 0 条评论,133人围观)

还没有评论,来说两句吧...

相关阅读