# -*- coding: utf-8 -*-
"""
Created on Tue Mar 21 18:29:17 2017
@author: Administrator
"""
import cPickle
import gzip
import numpy as np
import matplotlib.pyplot as plt
f = gzip.open('mnist.pkl.gz', 'rb')
train_set, valid_set, test_set = cPickle.load(f)
f.close()
tx,ty=train_set;
#查看训练样本
print np.shape(tx)#可以看到tx大小为(50000,28*28)的二维矩阵
print np.shape(ty)#可以看到ty大小为(50000,1)的矩阵
#图片显示
A=tx[108].reshape(28,28)#第八个训练样本
Y=ty[108]
print Y
#plt.show(A,cmap='gray')
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(A,cmap='gray')
plt.show()
卷积神经网路---第一小例子:解压gz,显示图片
最新推荐文章于 2023-12-12 20:33:20 发布