MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / __next__

Method __next__

AutoML/darts-master/rnn/data.py:100–116  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

98 self.pad_id = pad_id
99
100 def __next__(self):
101 if self.idx >= len(self.sort_sents):
102 raise StopIteration
103
104 batch_size = min(self.batch_size, len(self.sort_sents)-self.idx)
105 batch = self.sort_sents[self.idx:self.idx+batch_size]
106 max_len = max([s.size(0) for s in batch])
107 tensor = torch.LongTensor(max_len, batch_size).fill_(self.pad_id)
108 for i in range(len(batch)):
109 s = batch[i]
110 tensor[:s.size(0),i].copy_(s)
111 if self.cuda:
112 tensor = tensor.cuda()
113
114 self.idx += batch_size
115
116 return tensor
117
118 next = __next__
119

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected