Mercurial > pylearn
comparison _test_dataset.py @ 293:4bfdda107a17
still merging
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Fri, 06 Jun 2008 16:13:17 -0400 |
parents | 174374d59405 |
children | f7924e13e426 |
comparison
equal
deleted
inserted
replaced
292:174374d59405 | 293:4bfdda107a17 |
---|---|
45 | 45 |
46 def test_iterate_over_examples(array,ds): | 46 def test_iterate_over_examples(array,ds): |
47 #not in doc!!! | 47 #not in doc!!! |
48 i=0 | 48 i=0 |
49 for example in range(len(ds)): | 49 for example in range(len(ds)): |
50 wanted = array[example][:3] | |
51 returned = ds[example]['x'] | |
52 if (wanted != returned).all(): | |
53 print 'returned:', returned | |
54 print 'wanted:', wanted | |
50 assert (ds[example]['x']==array[example][:3]).all() | 55 assert (ds[example]['x']==array[example][:3]).all() |
51 assert ds[example]['y']==array[example][3] | 56 assert ds[example]['y']==array[example][3] |
52 assert (ds[example]['z']==array[example][[0,2]]).all() | 57 assert (ds[example]['z']==array[example][[0,2]]).all() |
53 i+=1 | 58 i+=1 |
54 assert i==len(ds) | 59 assert i==len(ds) |
224 assert (numpy.append(x[id],y[id])==array[(i+4)%array.shape[0]]).all() | 229 assert (numpy.append(x[id],y[id])==array[(i+4)%array.shape[0]]).all() |
225 i+=1 | 230 i+=1 |
226 assert i==m.n_batches*m.minibatch_size | 231 assert i==m.n_batches*m.minibatch_size |
227 del x,y,i,id | 232 del x,y,i,id |
228 | 233 |
229 #@todo: we can't do minibatch bigger then the size of the dataset??? | 234 assert not have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array)+1,offset=0) |
230 assert have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array)+1,offset=0) | |
231 assert not have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array),offset=0) | 235 assert not have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array),offset=0) |
232 | 236 |
233 def test_ds_iterator(array,iterator1,iterator2,iterator3): | 237 def test_ds_iterator(array,iterator1,iterator2,iterator3): |
234 l=len(iterator1) | 238 l=len(iterator1) |
235 i=0 | 239 i=0 |