changeset 629:4e7781972999

merge
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 19 Jan 2009 18:35:43 -0500
parents 739720896d61 (diff) 886d8f289fb7 (current diff)
children 24237be52cfd a11b7fbf3171
files pylearn/dbdict/api0.py
diffstat 2 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/datasets/MNIST.py	Mon Jan 19 00:58:06 2009 -0500
+++ b/pylearn/datasets/MNIST.py	Mon Jan 19 18:35:43 2009 -0500
@@ -8,7 +8,7 @@
 
 from ..io.amat import AMat
 from .config import data_root
-from .dataset import dataset_factory, Dataset
+from .dataset import Dataset
 
 def head(n=10, path=None):
     """Load the first MNIST examples.
@@ -50,15 +50,23 @@
     return rval
 
 
+def full():
+    return train_valid_test()
 
-@dataset_factory('MNIST')
+def first_1k():
+    return train_valid_test(ntrain=1000, nvalid=200, ntest=200)
+
+def first_10k():
+    return train_valid_test(ntrain=10000, nvalid=2000, ntest=2000)
+
+#old method from factory idea days... delete when ready -JB20090119
 def mnist_factory(variant="", ntrain=None, nvalid=None, ntest=None):
     if variant=="":
-        return train_valid_test()
+        return full()
     elif variant=="1k":
-        return train_valid_test(ntrain=1000, nvalid=200, ntest=200)
+        return first_1k()
     elif variant=="10k":
-        return train_valid_test(ntrain=10000, nvalid=2000, ntest=2000)
+        return first_10k()
     elif variant=="custom":
         return train_valid_test(ntrain=ntrain, nvalid=nvalid, ntest=ntest)
     else:
--- a/pylearn/dbdict/api0.py	Mon Jan 19 00:58:06 2009 -0500
+++ b/pylearn/dbdict/api0.py	Mon Jan 19 18:35:43 2009 -0500
@@ -490,6 +490,18 @@
 
     def session(h_self):
         return h_self._session_fn()
+
+    def get(h_self, id):
+        s = h_self.session()
+        rval = s.query(h_self._Dict).get(id)
+        if rval:
+            #eagerload hack
+            str(rval)
+            rval.id
+        s.close()
+        return rval
+
+
         
 
 def db_from_engine(engine,