gpt4 book ai didi

python - 属性错误: module 'tensorflow' has no attribute 'keras'

转载 作者:行者123 更新时间:2023-12-02 06:20:23 24 4
gpt4 key购买 nike

使用下面的代码加载 CIFAR-10 数据集最初是有效的。

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()

但是,在环境中安装 Keras 后,运行上面的行会导致错误:

>>> AttributeError: module 'tensorflow' has no attribute 'keras'

我的解决方案是改用 Keras CIFAR-10 加载模块:

(x_train, y_train), (x_test, y_test) = cifar10.load_data()

我想了解为什么 pip 安装 Keras 会弄乱 tf.keras 包。

最佳答案

您可能正在运行早于 tf.keras 的旧版本 tensorflow。更新您的 tensorflow 版本。

关于python - 属性错误: module 'tensorflow' has no attribute 'keras' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51414808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com