changeset 951:5d70dfc70ec0

added comments and image-rendering code to cifar-10
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 18 Aug 2010 13:00:19 -0400
parents faa658da89c2
children 5f80351bc762
files pylearn/dataset_ops/cifar10.py pylearn/datasets/cifar10.py
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- 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
+
+