2022.4.15

使用tensorflow出现的错误:

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

解决方法:

将代码:

import tensorflow as tf

替换为

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

替换后我的pycharm里compat下面会显示红波浪线,但是仍然可以运行

 

posted @ 2022-04-15 15:24  鯨落  阅读(24)  评论(0编辑  收藏  举报