All the examples are based on the following URL
http://www.deeplearning.net/tutorial/
Backgrounds of all examples in this tutorial are the same,all of these are train models with data in mnist,
mnist is a binary data packed with python pickle tool,as its data structure
((train_datas[float, float, float, ......], train_labels[int, int, int.....]),
(valid_datas[], valid_labels[]),
(test_datas[], test_labels[]))
each data is a 28*28 float array which indicates the lightness of pixel in character image extracted from minst,
each label is a integer from 0~9 which express the correct answer of character image which waited for recongnize,
Data used in the following example is decreased by myself,origin data is split in the proportion train:valid:test = 50000:10000:10000
It will spend a lot of time to extract mnist into memory.We don't need so much data if we only to learn the method,theory or principle of mnist
there are two decrease data package,respectively is 5000:1000:1000 version and 500:100:100 version which are upload in network disk
http://pan.baidu.com/share/link?shareid=2658861284&uk=2702985576
Method is implemented in python coding language with the theano which is a pop python framework in deep learning world,You should have the priori knowledge by yourself http://www.deeplearning.net/software/theano/
Here is the python code implemented with 500 count version hoped to give your some help to understand the data structure of mnist
'''
Created on Sep 4, 2013
@author: blacklaw
'''
from numpy import *
import cPickle as pickle
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.font_manager as font
def draw(arr):
for i in range(len(arr) / 28):
for j in range(28):
if arr[28 * i + j] == 0:
print ' ',
else:
print '*',
print
if __name__ == '__main__':
# load data
f = open('../data/mnist.500.pkl')
(train, train_label), (valid, valid_label), (test, test_label) = pickle.load(f)
# draw train data[7] in shell
draw(train[7])
# set plot
mpl.rcParams['xtick.labelsize'] = 0
mpl.rcParams['ytick.labelsize'] = 0
mpl.rcParams['xtick.direction'] = 'in'
mpl.rcParams['ytick.direction'] = 'in'
# draw 10 * 8 image
fig = plt.figure()
x_length = 10; y_length = 8
for i in range(x_length * y_length):
im = train[i].reshape(28, 28)
plotwindow = fig.add_subplot(y_length, x_length, i + 1)
plt.imshow(im , cmap='gray')
plt.text(0, 8, train_label[i], color = 'r')
plt.show()
Computational result:
* * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * *
* * * * *
* * * * * *
* * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * *
* * * *
* * * *
* * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * *