MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / wrapper

Method wrapper

NLP/UNIMO/src/reader/retrieval_reader.py:469–493  ·  view source on GitHub ↗

wrapper

()

Source from the content-addressed store, hash-verified

467 def data_generator(self):
468 """data_generator"""
469 def wrapper():
470 """"wrapper"""
471 def batch_reader():
472 """batch_reader"""
473 batch_records = []
474 self.current_example = 0
475 for sample in self.shuffle_samples(self.read_caption_id()):
476 self.current_example = self.current_example + 1
477 if len(batch_records) < self.batch_size:
478 batch_records.append(sample)
479 if len(batch_records) == self.batch_size:
480 yield self._prepare_batch_data(batch_records)
481 batch_records = []
482 if batch_records:
483 yield self._prepare_batch_data(batch_records)
484
485 all_dev_batches = []
486 for batch_data in batch_reader():
487 if len(all_dev_batches) < self.trainers_num:
488 all_dev_batches.append(batch_data)
489 if len(all_dev_batches) == self.trainers_num:
490 yield all_dev_batches[self.trainer_id]
491 all_dev_batches = []
492 if self.trainer_id < len(all_dev_batches):
493 yield all_dev_batches[self.trainer_id]
494 return wrapper
495
496

Callers

nothing calls this directly

Calls 2

batch_readerFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected