def _batches(self):
"""
Partition the data into consecutive data sets of the specified batch size.
:return: batched data
:rtype: DataFrame iterator
"""
t1 = partition_all(self.batch_size, self.data[text_1])
t2 = partition_all(self.batch_size, self.data[text_2])
if self._labeled:
l = partition_all(self.batch_size, self.data[label].cat.codes)
batches = zip(t1, t2, l)
else:
batches = zip(t1, t2)
for batch in batches:
if self._labeled:
columns = [text_1, text_2, label]
else:
columns = [text_1, text_2]
yield DataFrame(dict(zip(columns, batch)), columns=columns)
评论列表
文章目录