649453932 / Chinese-Text-Classification-Pytorch

中文文本分类,TextCNN,TextRNN,FastText,TextRCNN,BiLSTM_Attention,DPCNN,Transformer,基于pytorch,开箱即用。
MIT License
5.27k stars 1.23k forks source link

utils.py中的def __next__(self)好像有一点小问题 #15

Closed hugen1996 closed 4 years ago

hugen1996 commented 4 years ago

def next(self): if self.residue and self.index == self.n_batches: batches = self.batches[self.index * self.batch_size: len(self.batches)] self.index += 1 batches = self._to_tensor(batches) return batches

    elif self.index > self.n_batches:
        self.index = 0
        raise StopIteration
    else:
        batches = self.batches[self.index * self.batch_size: (self.index + 1) * self.batch_size]
        self.index += 1
        batches = self._to_tensor(batches)
        return batches

这里应该是elif self.index >= self.n_batches吧????

XXWong commented 4 years ago

同发现,如果没有等于,当len(batches)整除batch_size的时候就会出问题了

649453932 commented 4 years ago

万分感谢!已改正