属性错误:模块“tensorflow.compat.v2.__internal__"没有属性“tf2" [英] AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'
本文介绍了属性错误:模块“tensorflow.compat.v2.__internal__"没有属性“tf2"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
上图为:错误是这样的:
Above is the image: The error is this:
LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'
谢谢
推荐答案
从 Tensorflow 2.x
开始,keras
不再维护,它成为 keras
的一部分代码>张量流代码>.我建议不要使用 import keras
,你应该尝试 from tensorflow import keras
或 import tensorflow as tf
并使用 tf.keras代码>.
From Tensorflow 2.x
onward, keras
is no longer maintained and it became a part of Tensorflow
. I would recommend instead of import keras
, you should try from tensorflow import keras
or import tensorflow as tf
and use tf.keras
.
您可以从 tensorflow
导入 Sequential
模块,如下所示
You can import Sequential
module from tensorflow
as shown below
import tensorflow as tf
from tf.keras import Sequential
For more information you can refer this and this
这篇关于属性错误:模块“tensorflow.compat.v2.__internal__"没有属性“tf2"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文