属性错误:模块“tensorflow.compat.v2.__internal__"没有属性“tf2" [英] AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

查看:45
本文介绍了属性错误:模块“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 kerasimport 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

有关更多信息,您可以参考this这个

For more information you can refer this and this

这篇关于属性错误:模块“tensorflow.compat.v2.__internal__"没有属性“tf2"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆