changeset 1455:93e5ce7ccd6d

tinyimages_op gains loop and shuffle kwargs
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 04 Apr 2011 19:01:12 -0400
parents 283fb236f104
children 272879b84d30
files pylearn/dataset_ops/tinyimages.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/dataset_ops/tinyimages.py	Mon Apr 04 19:00:53 2011 -0400
+++ b/pylearn/dataset_ops/tinyimages.py	Mon Apr 04 19:01:12 2011 -0400
@@ -34,7 +34,7 @@
 # pre-processed data should be stored.  For now it is stored in the current working directory.
 #
 
-def tinyimages_op(s_idx):
+def tinyimages_op(s_idx, loop=False, shuffled=False):
     """Return symbolic tiny_images[s_idx]
 
     If s_idx is a scalar, the return value is a tensor3 of shape 32,32,3 and
@@ -42,9 +42,15 @@
     If s_idx is a vector of len N, the return value
     is a tensor4 of shape N,32,32,3 and dtype uint8.
     """
+    if loop:
+        s_idx = s_idx % tinyimages.n_images
+    if shuffled:
+        fn = tinyimages.get_memmapped_file
+    else:
+        fn = tinyimages.get_shuffled_memmapped_file
     op = TensorFnDataset('uint8',
             bcast=(False, False, False),
-            fn=tinyimages.get_memmapped_file,
+            fn=fn,
             single_shape=(32,32,3))
     return op(s_idx)