首页 > 解决方案 > CIFAR10 数据集没有属性 load_data()

问题描述

我正在使用 tensorflow 2.0.1 版。在我的 Jupyter 笔记本中,我使用:

(train_x, train_y), (test_x, test_y) = tf.keras.datasets.cifar100.load_data()

但是,它不起作用,我收到以下错误:

AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.datasets.cifar10' has no attribute 'load_data'

此外,在自动完成中,我看到 CIFAR100 的 load_data(),但 CIFAR10 没有显示任何内容。

标签: tensorflowkerastensorflow-datasetstf.keras

解决方案


我可以cifar10使用load_data如下所示的方法加载数据集

import tensorflow as tf
print(tf.__version__)
(train_x, train_y), (test_x, test_y) = tf.keras.datasets.cifar10.load_data()

输出:

2.0.1
Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
170500096/170498071 [==============================] - 5s 0us/step

有关更多信息,您可以参考加载 CIFAR10 数据集


推荐阅读