【问题标题】:AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'AttributeError:模块“tensorflow.compat.v2.__internal__”没有属性“tf2”
【发布时间】:2021-05-08 15:58:53
【问题描述】:

enter image description here

上图是: 错误是这样的:

LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

谢谢

【问题讨论】:

  • 你找到解决方案了吗?

标签: tensorflow2.0


【解决方案1】:

Tensorflow 2.x 开始,keras 不再维护,它成为Tensorflow 的一部分。我建议您不要使用import keras,而是尝试from tensorflow import kerasimport tensorflow as tf 并使用tf.keras

您可以从tensorflow 导入Sequential 模块,如下所示

import tensorflow as tf
from tf.keras import Sequential

更多信息可以参考thisthis

【讨论】:

    猜你喜欢
    • 2021-08-14
    • 1970-01-01
    • 2023-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-14
    • 2021-10-15
    相关资源
    最近更新 更多