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