diff datasets/MNIST.py @ 471:45b3eb429c15

added train_valid_test
author James Bergstra <bergstrj@iro.umontreal.ca>
date Thu, 23 Oct 2008 13:26:11 -0400
parents bd937e845bbb
children 11e0357f06f4
line wrap: on
line diff
--- a/datasets/MNIST.py	Wed Oct 22 15:56:53 2008 -0400
+++ b/datasets/MNIST.py	Thu Oct 23 13:26:11 2008 -0400
@@ -29,3 +29,12 @@
     return head(n=None, path=path)
 
 
+def train_valid_test(path=None, ntrain=50000, nvalid=10000, ntest=10000):
+    all_x, all_targ = all(path=path)
+
+    train = all_x[0:ntrain], all_targ[0:ntrain]
+    valid = all_x[ntrain:ntrain+nvalid], all_targ[ntrain:ntrain+nvalid]
+    test = all_x[ntrain+nvalid:ntrain+nvalid+ntest], all_targ[ntrain+nvalid:ntrain+nvalid+ntest]
+
+    return train, valid, test
+