下载cifar10数据集后,想显示几张图片,把数据转换为图片显示;
cifar10下载网址链接
1、数据读入
上面下载数据集的页面给出了数据格式和数据读入方式;下载数据集后直接用给出方法读入数据:
def unpickle(file):
import cPickle
with open(file,'rb')as fo:
dict=cPickle.load(fo)
return dict
cifar10_data=unpickle("./cifar-10-batches-py/data_batch_1")
2、读入后返回一个字典dict,内部元素包含:
key和值结果如下:
<type 'dict'>
4
key: data
type <type 'numpy.ndarray'>
key: labels
type <type 'list'>
key: batch_label
type <type 'str'>
key: filenames
type <type 'list'>
对应各对象的shape如下:
('cifar10_data_type:', (10000, 3072))
('cifar10_labels:', 10000)
('cifar10_batch_label', 'training batch 1 of 5')
('cifar10_filenames', 10000)
3、使用matplotlib显示图片: