def __init__(self):
super().__init__()
stack = self._stack
# classes
self.classes_ = [0, 1, 2]
self.average_classes = [0, 2]
# data
self.data_dir = 'data/imdb'
with temp_chdir(self.data_dir):
self.train_objs = JSONDecoder(stack.enter_context(open('train.json')))
self.train_docs = FieldExtractor(self.train_objs, 'text')
self.train_labels = np.fromiter(FieldExtractor(self.train_objs, 'label'), 'int32')
unsup_sr = stack.enter_context(open('unsup.json'))
self.unsup_docs = BalancedSlice([FieldExtractor(unsup_sr, 'text')])
self.val_objs = JSONDecoder(stack.enter_context(open('val.json')))
self.val_docs = FieldExtractor(self.val_objs, 'text')
self.val_labels = FieldExtractor(self.val_objs, 'label')
self.test_objs = JSONDecoder(stack.enter_context(open('test.json')))
self.test_docs = FieldExtractor(self.test_objs, 'text')
self.test_labels = FieldExtractor(self.test_objs, 'label')
评论列表
文章目录