Mercurial > pylearn
diff datasets/MNIST.py @ 504:19ab9ce916e3
slightly more sophisticated system for finding the mnist data
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 29 Oct 2008 11:38:49 -0400 |
parents | 11e0357f06f4 |
children | 74b3e65f5f24 |
line wrap: on
line diff
--- a/datasets/MNIST.py Wed Oct 29 03:29:18 2008 -0400 +++ b/datasets/MNIST.py Wed Oct 29 11:38:49 2008 -0400 @@ -7,9 +7,7 @@ from ..amat import AMat -default_path = '/u/bergstrj/pub/data/mnist.amat' -"""the location of a file containing mnist data in .amat format""" - +from .config import MNIST_amat def head(n=10, path=None): """Load the first MNIST examples. @@ -19,10 +17,16 @@ is the label of the i'th row of x. """ - path = path if path is not None else default_path + path = MNIST_amat if path is None else path dat = AMat(path=path, head=n) + try: + assert dat.input.shape[0] == n + assert dat.target.shape[0] == n + except Exception , e: + raise Exception("failed to read MNIST data", (dat, e)) + return dat.input, numpy.asarray(dat.target, dtype='int64').reshape(dat.target.shape[0]) def train_valid_test(ntrain=50000, nvalid=10000, ntest=10000, path=None):