def _get_next_minibatch(self): try: dataBlob, labelBlob,weightBlob = self.iterator.next() except StopIteration: filenames = data.get_sentence(self.config.get('datafile')) labels = data.get_labels(self.config.get('labelfile')) weights = data.get_sample_weights(self.config.get('labelfile')) self.iterator = iter(self.sampleIter(filenames,labels,weights)) dataBlob, labelBlob,weightBlob = self.iterator.next() return {'data': dataBlob, 'labels': labelBlob, 'weights': weightBlob }
def setup(self, bottom, top): """Setup the ResamplerDataLayer.""" # parse the layer parameter string layer_config = self.param_str self.config = util.load_module(layer_config).config filenames = data.get_sentence(self.config.get('datafile')) labels = data.get_labels(self.config.get('labelfile')) weights = data.get_sample_weights(self.config.get('labelfile')) self.sampleIter = iterator.WeightedIterator(self.config, batch_size=self.config.get('batch_size')) self.iterator = iter(self.sampleIter(filenames,labels,weights)) self._name_to_top_map = { 'data': 0, 'labels': 1, 'weights':2 } top[0].reshape(self.config.get('batch_size'), 3, self.config.get('h'), self.config.get('w')) top[1].reshape(self.config.get('batch_size')) top[2].reshape(self.config.get('batch_size'))