[深度学习]cifar10数据集使用方法

cifar10训练数据集下载

链接:https://pan.baidu.com/s/1Qlp2G5xlECM6dyvUivWnFg
提取码:s32t

import pickle
import numpy as np
import os

CIFAR_DIR = "./../cifar-10-batches-py"
print(os.listdir(CIFAR_DIR))
with open(os.path.join(CIFAR_DIR, "data_batch_1"), 'rb') as f:
    data = pickle.load(f, encoding='bytes')
    print(type(data))
    print(data.keys())
    print(type(data[b'data']))
    print(type(data[b'labels']))
    print(type(data[b'batch_label']))
    print(type(data[b'filenames']))
    print(data[b'data'].shape)
    print(data[b'data'][0:2])
    print(data[b'labels'][0:2])
    print(data[b'batch_label'])
    print(data[b'filenames'][0:2])

# 32 * 32 = 1024 * 3 = 3072
# RR-GG-BB = 3072
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow

image_arr = data[b'data'][100]
image_arr = image_arr.reshape((3, 32, 32)) # 32 32 3
image_arr = image_arr.transpose((1, 2, 0))
    
%matplotlib inline

imshow(image_arr)

图片解析结果显示

从结果看出index为100的图片显示出力量敞篷轿车
[深度学习]cifar10数据集使用方法_第1张图片

你可能感兴趣的:(深度学习,神经网络,深度学习)