comparison datasets/smallNorb.py @ 508:60b7dd5be860

scrapped ulimit in smallnorb
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 29 Oct 2008 18:23:34 -0400
parents b8e6de17eaa6
children
comparison
equal deleted inserted replaced
507:b8e6de17eaa6 508:60b7dd5be860
30 30
31 normalize_pixels True will divide the values by 255, which makes sense in conjunction 31 normalize_pixels True will divide the values by 255, which makes sense in conjunction
32 with dtype=float32 or dtype=float64. 32 with dtype=float32 or dtype=float64.
33 33
34 """ 34 """
35 #set ulimit to an integer, and disable reading of the test_xxx files to load only a
36 #subset of the data
37 ulimit=None
38 def downsample(dataset): 35 def downsample(dataset):
39 return dataset[:, 0, ::downsample_amt, ::downsample_amt] 36 return dataset[:, 0, ::downsample_amt, ::downsample_amt]
40 37
41 samples = downsample(read(open(self.train_dat), slice(None,ulimit))) 38 samples = downsample(read(open(self.train_dat)))
42 samples = numpy.vstack((samples, downsample(read(open(self.test_dat))))) 39 samples = numpy.vstack((samples, downsample(read(open(self.test_dat)))))
43 samples = numpy.asarray(samples, dtype=dtype) 40 samples = numpy.asarray(samples, dtype=dtype)
44 if normalize_pixels: 41 if normalize_pixels:
45 samples *= (1.0 / 255.0) 42 samples *= (1.0 / 255.0)
46 43
47 labels = read(open(self.train_cat), slice(0,ulimit)) 44 labels = read(open(self.train_cat))
48 labels = numpy.hstack((labels, read(open(self.test_cat)))) 45 labels = numpy.hstack((labels, read(open(self.test_cat))))
49 46
50 infos = read(open(self.train_info), slice(0,ulimit)) 47 infos = read(open(self.train_info))
51 infos = numpy.vstack((infos, read(open(self.test_info)))) 48 infos = numpy.vstack((infos, read(open(self.test_info))))
52 49
53 return samples, labels, infos 50 return samples, labels, infos
54 51
55 def smallnorb_iid(ntrain=29160, nvalid=9720, ntest=9720, dtype='float64', normalize_pixels=True): 52 def smallnorb_iid(ntrain=29160, nvalid=9720, ntest=9720, dtype='float64', normalize_pixels=True):