comparison pylearn/datasets/MNIST.py @ 1484:83d3c9ee6d65

* changed MNIST dataset to use config.get_filepath_in_roots mechanism
author gdesjardins
date Tue, 05 Jul 2011 11:01:51 -0400
parents 6ade5b39b773
children
comparison
equal deleted inserted replaced
1483:4727a7e4d506 1484:83d3c9ee6d65
4 4
5 import os 5 import os
6 import numpy 6 import numpy
7 7
8 from pylearn.io.pmat import PMat 8 from pylearn.io.pmat import PMat
9 from pylearn.datasets.config import data_root # config
10 from pylearn.datasets.dataset import Dataset 9 from pylearn.datasets.dataset import Dataset
10 import config
11 11
12 def head(n=10, path=None): 12 def head(n=10, path=None):
13 """Load the first MNIST examples. 13 """Load the first MNIST examples.
14 14
15 Returns two matrices: x, y. x has N rows of 784 columns. Each row of x represents the 15 Returns two matrices: x, y. x has N rows of 784 columns. Each row of x represents the
16 28x28 grey-scale pixels in raster order. y is a vector of N integers. Each element y[i] 16 28x28 grey-scale pixels in raster order. y is a vector of N integers. Each element y[i]
17 is the label of the i'th row of x. 17 is the label of the i'th row of x.
18 18
19 """ 19 """
20 if path is None: 20 if path is None:
21 path = os.path.join(data_root(), 'mnist','mnist_all.pmat') 21 # dataset lookup through $PYLEARN_DATA_ROOT
22 _path = os.path.join('mnist', 'mnist_all.pmat')
23 path = config.get_filepath_in_roots(_path)
22 24
23 dat = PMat(fname=path) 25 dat = PMat(fname=path)
24 26
25 rows=dat.getRows(0,n) 27 rows=dat.getRows(0,n)
26 28