def test_ndarray_batch_source(self): # Make sure that with enough epochs we sample everything. stream = RandomFixedSizeCrop(self.batch_stream, (5, 4), which_sources=('source1', )) seen_indices = numpy.array([], dtype='uint8') for i in range(30): for batch in stream.get_epoch_iterator(): assert batch[0].shape[1:] == (3, 5, 4) assert batch[0].shape[0] in (1, 2) seen_indices = numpy.union1d(seen_indices, batch[0].flatten()) if 3 * 7 * 5 == len(seen_indices): break else: assert False
def test_ndarray_batch_source(self): # Make sure that with enough epochs we sample everything. stream = RandomFixedSizeCrop(self.batch_stream, (5, 4), which_sources=('source1',)) seen_indices = numpy.array([], dtype='uint8') for i in range(30): for batch in stream.get_epoch_iterator(): assert batch[0].shape[1:] == (3, 5, 4) assert batch[0].shape[0] in (1, 2) seen_indices = numpy.union1d(seen_indices, batch[0].flatten()) if 3 * 7 * 5 == len(seen_indices): break else: assert False
def test_list_batch_source(self): # Make sure that with enough epochs we sample everything. stream = RandomFixedSizeCrop(self.batch_stream, (5, 4), which_sources=('source2', )) seen_indices = numpy.array([], dtype='uint8') for i in range(30): for batch in stream.get_epoch_iterator(): for example in batch[1]: assert example.shape == (2, 5, 4) seen_indices = numpy.union1d(seen_indices, example.flatten()) assert len(batch[1]) in (1, 2) if self.source2_biggest == len(seen_indices): break else: assert False
def test_list_batch_source(self): # Make sure that with enough epochs we sample everything. stream = RandomFixedSizeCrop(self.batch_stream, (5, 4), which_sources=('source2',)) seen_indices = numpy.array([], dtype='uint8') for i in range(30): for batch in stream.get_epoch_iterator(): for example in batch[1]: assert example.shape == (2, 5, 4) seen_indices = numpy.union1d(seen_indices, example.flatten()) assert len(batch[1]) in (1, 2) if self.source2_biggest == len(seen_indices): break else: assert False