属性错误:模块“tensorflow”没有属性“keras”。

3

使用以下代码加载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()

我想了解为什么安装Keras时使用pip会影响tf.keras包。
1个回答

0

你可能正在运行一个旧版本的tensorflow,它还没有tf.keras。请更新你的tensorflow版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接