tensorflow2报错提示 module ‘tensorflow‘ has no attribute ‘placeholder‘

tensorflow2运行代码提示:

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

查找资料说是tensorflow2中没有placeholder,需要将

import tensorflow as tf

改成

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

但是会在compat下边有红色波浪线

继续查。。。有人说运行:

pip install --ignore-installed --upgrade --ignore-installed tensorflow

但是并不管用。。。

抱着试试看心态运行了代码,发现这个compat报错并不影响,正常运行了,很奇怪。。。不知道为啥

你可能感兴趣的:(tensorflow2报错提示 module ‘tensorflow‘ has no attribute ‘placeholder‘)