MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / TIMITBatch

Class TIMITBatch

examples/CTC-TIMIT/timitdata.py:36–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class TIMITBatch(ProxyDataFlow):
37
38 def __init__(self, ds, batch):
39 self.batch = batch
40 self.ds = ds
41
42 def __len__(self):
43 return len(self.ds) // self.batch
44
45 def __iter__(self):
46 itr = self.ds.__iter__()
47 for _ in range(self.__len__()):
48 feats = []
49 labs = []
50 for _ in range(self.batch):
51 feat, lab = next(itr)
52 feats.append(feat)
53 labs.append(lab)
54 batchfeat = batch_feature(feats)
55 batchlab = sparse_label(labs)
56 seqlen = np.asarray([k.shape[0] for k in feats])
57 yield [batchfeat, batchlab[0], batchlab[1], batchlab[2], seqlen]

Callers 1

get_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…