# HG changeset patch # User James Bergstra # Date 1282150819 14400 # Node ID 5d70dfc70ec06563fd61fc29670ec6ac7b498019 # Parent faa658da89c2b2546ca5b756baa297a36c7ba290 added comments and image-rendering code to cifar-10 diff -r faa658da89c2 -r 5d70dfc70ec0 pylearn/dataset_ops/cifar10.py --- a/pylearn/dataset_ops/cifar10.py Wed Aug 18 12:59:47 2010 -0400 +++ b/pylearn/dataset_ops/cifar10.py Wed Aug 18 13:00:19 2010 -0400 @@ -59,7 +59,9 @@ def cifar10(s_idx, split, dtype='float64', rasterized=False, color='grey'): - """ + """ + Returns a pair (img, label) of theano expressions for cifar-10 samples + :param s_idx: the indexes :param split: diff -r faa658da89c2 -r 5d70dfc70ec0 pylearn/datasets/cifar10.py --- a/pylearn/datasets/cifar10.py Wed Aug 18 12:59:47 2010 -0400 +++ b/pylearn/datasets/cifar10.py Wed Aug 18 13:00:19 2010 -0400 @@ -88,3 +88,19 @@ def first_1k(dtype='uint8', ntrain=1000, nvalid=200, ntest=200): return cifar10(dtype, ntrain, nvalid, ntest) + +def tile_rasterized_examples(X): + """Returns an ndarray that is ready to be passed to `image_tiling.save_tiled_raster_images` + + This function is for the `x` matrices in the cifar dataset, or for the weight matrices + (filters) used to multiply them. + """ + X = X.astype('float32') + r = X[:,:1024] + g = X[:,1024:2048] + b = X[:,2048:] + from pylearn.io.image_tiling import tile_raster_images + rval = tile_raster_images((r,g,b,None), img_shape=(32,32)) + return rval + +