显示cifar图片

# coding:utf-8

import numpy as np
import matplotlib.pyplot as plt
import pickle

FILE_PATH = r"D:\source\technology_source\aisource\ds\cifar-10-python\unzip\data_batch_1"
with open(FILE_PATH, 'rb') as fo:
    data_dict = pickle.load(fo, encoding='bytes')
    X = data_dict[b'data']
    Y = data_dict[b'labels']
    X = X.reshape(10000, 3, 32, 32).transpose(0, 2, 3, 1).astype("uint8")
    Y = np.array(Y)

im = X[2000]  # 显示第2000张图片
fig = plt.figure()
plt.axis('off')
plt.imshow(im)
plt.show()
plt.close()

posted on 2017-06-01 11:21  荷楠仁  阅读(672)  评论(0编辑  收藏  举报

导航