MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / SortishSampler

Class SortishSampler

seq2seq/utils.py:333–343  ·  view source on GitHub ↗

Go through the text data by order of src length with a bit of randomness. From fastai repo.

Source from the content-addressed store, hash-verified

331
332
333class SortishSampler(Sampler):
334 "Go through the text data by order of src length with a bit of randomness. From fastai repo."
335
336 def __init__(self, data, batch_size, shuffle=True):
337 self.data, self.bs, self.shuffle = data, batch_size, shuffle
338
339 def __len__(self) -> int:
340 return len(self.data)
341
342 def __iter__(self):
343 return iter(sortish_sampler_indices(self.data, self.bs, shuffle=self.shuffle))
344
345
346def sortish_sampler_indices(data: List, bs: int, shuffle=True) -> np.array:

Callers 1

make_sortish_samplerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected