SequentialSampler
| 132 | |
| 133 | |
| 134 | class SequentialSampler(object): |
| 135 | """SequentialSampler""" |
| 136 | def __init__(self, batch_size, corpus_length): |
| 137 | self.batch_size = batch_size |
| 138 | self.corpus_length = corpus_length |
| 139 | |
| 140 | def __iter__(self): |
| 141 | """iter""" |
| 142 | batch = [] |
| 143 | for i in range(self.corpus_length): |
| 144 | batch.append(i) |
| 145 | if len(batch) == self.batch_size: |
| 146 | yield batch |
| 147 | batch = [] |
| 148 | else: |
| 149 | if len(batch): |
| 150 | yield batch |
| 151 | |
| 152 | |
| 153 | def batchify( |