Deep Learning_mnist background introduction

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:

                                                       
                                                  
                      * * * * * * * * * * *            
                  * * * * * * * * * * * * * *          
                  * * * * * * * * * * * * * *          
                  * * * * * * * * * * * * * *          
                  * * * *         * * * * * *          
                                  * * * * *            
                                * * * * * *            
                            * * * * * * * *            
                  * * * * * * * * * * * *              
                * * * * * * * * * * *                  
                * * * * * * * * * * * *                
                  * * * * * * * * * * *                
                                * * * *                
                                * * * *                
            * * *             * * * * *                
          * * * *         * * * * * * *                
          * * * * * * * * * * * * * *                  
          * * * * * * * * * * * * *                    
          * * * * * * * * * * *                        
            * * * * * * *                              
                                                       







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值