changeset 1475:e7401822d596

Pylearn Dataset wrapper for MNIST+rotate+background dataset used in ICML07 (new version) and for contracting auto-encoder work.
author gdesjardins
date Wed, 18 May 2011 22:15:42 -0400
parents a57f4839a9d8
children 8c10bda4bb5f
files pylearn/datasets/icml07.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/datasets/icml07.py	Wed May 18 10:52:42 2011 -0400
+++ b/pylearn/datasets/icml07.py	Wed May 18 22:15:42 2011 -0400
@@ -5,6 +5,30 @@
 
 from config import get_filepath_in_roots
 from pylearn.io.amat import AMat
+from pylearn.datasets.config import data_root # config
+from pylearn.datasets.dataset import Dataset
+
+class MNIST_rotated_background(object):
+
+    def __init__(self, n_train=62000, n_valid=0, n_test=0):
+
+        basedir = os.path.join(data_root(), 'icml07data', 'npy')
+
+        x_all = numpy.load(os.path.join(basedir, 'mnist_rotated_background_images_inputs.npy'))
+        y_all = numpy.load(os.path.join(basedir, 'mnist_rotated_background_images_labels.npy'))
+
+        vstart = n_train
+        tstart = n_train + n_valid
+
+        self.train = Dataset.Obj(x=x_all[:n_train], y=y_all[:n_train])
+        self.valid = Dataset.Obj(x=x_all[vstart:vstart+n_valid],
+                                 y=y_all[vstart:vstart+n_valid])
+        self.test  = Dataset.Obj(x=x_all[tstart:tstart+n_test],
+                                 y=y_all[tstart:tstart+n_test])
+
+        self.n_classes = 10
+        self.img_shape = (28,28)
+
 
 class DatasetLoader(object):
     """