MCPcopy Create free account
hub / github.com/baidu/DDParser / SequentialSampler

Class SequentialSampler

ddparser/parser/data_struct/data.py:134–150  ·  view source on GitHub ↗

SequentialSampler

Source from the content-addressed store, hash-verified

132
133
134class 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
153def batchify(

Callers 1

batchifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected