1、CIFAR-10数据集介绍
CIFAR-10数据集由10个类的60000个32x32彩色图像组成,每个类有6000个图像。有50000个训练图像和10000个测试图像。
数据集分为五个训练批次和一个测试批次,每个批次有10000个图像。测试批次包含来自每个类别的恰好1000个随机选择的图像。训练批次以随机顺序包含剩余图像,但一些训练批次可能包含来自一个类别的图像比另一个更多。更详细的介绍可参考:https://www.cnblogs.com/cloud-ken/p/8456878.html
我们先导入并且展示下部分数据:
from keras.datasets import cifar10
import matplotlib.pyplot as plt
# 首次使用时会在线进行数据集下载
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
print('图像数据格式: ', X_train.shape)
print("训练集:%2.0f,测试集:%2.0f" %(X_train.shape[0], X_test.shape[0]))
X_train[0][:5, :, 1] # 图片矩阵中的第一条记录,显示R矩阵前5行
fig, ax = plt.subplots()
ax.imshow(X_train[1])
fig = plt.figure(figsize = (20, 5))
for i in range(20):
ax = fig.add_subplot(2, 10, i + 1, xticks = [], yticks = [])
ax.imshow(X_train[i])
y_train[:20].reshape(2, 10)
<