首先鏈接一篇大牛的Theano文檔翻譯:http://www.cnblogs.com/xueliangliu/archive/2013/04/03/2997437.html
里面有mnist.pkl.gz 手動下載地址(因為代碼里也有自動下載方法)
那么我不是做圖像處理的,所以對圖像的存儲格式沒有什么概念,我要以其他方式輸入進theano程序中怎么辦呢?
於是就得分析它的存儲格式。代碼(logistic_sgd.py,line 195)注釋中說的已經很清楚了:
#train_set, valid_set, test_set format: tuple(input, target) #input is an numpy.ndarray of 2 dimensions (a matrix) #witch row's correspond to an example. target is a #numpy.ndarray of 1 dimensions (vector)) that have the same length as #the number of rows in the input. It should give the target #target to the example with the same index in the input.
那么就是說train_X是一個rows行2列的矩陣,train_Y是一個rows維的向量,而train_set是train_X和train_Y的一個組合
那么我們只需要讀文件構建矩陣和向量,然后share成theano程序里的類型就ok啦
===================割=========================
想不到后來又重拾DL,如今已經是今非昔比了啊
再次補充一下Mnist數據集的格式
import cPickle, gzip, numpy # Load the dataset f = gzip.open('mnist.pkl.gz', 'rb') train_set, valid_set, test_set = cPickle.load(f) f.close()
事實證明它會返回一個tuple,分別是train vali test集。
每個集有兩維,以train set為例,分別是(50000, 784) (50000,1)代表着5W個樣本和5W個label,
每個樣本有784個維度 = 28*28