Data manager for seq2seq
| 4 | |
| 5 | |
| 6 | class Seq2SeqDataManager(BaseDataManager): |
| 7 | """Data manager for seq2seq""" |
| 8 | |
| 9 | def __init__(self, args, model_args, preprocessor, process_id=0, num_workers=1): |
| 10 | # TODO: ref to a defination of the "args" and "model_args" |
| 11 | # --- what will they must contain? (e.g., data_file_path) |
| 12 | |
| 13 | super(Seq2SeqDataManager, self).__init__( |
| 14 | args, model_args, process_id, num_workers |
| 15 | ) |
| 16 | self.attributes = self.load_attributes(args.data_file_path) |
| 17 | self.preprocessor = preprocessor |
| 18 | |
| 19 | # TODO: maybe add this back, currently as the external usage |
| 20 | # self.load_next_round_data() |
| 21 | # self.train_loader, self.test_loader = self.get_data_loader() |
| 22 | |
| 23 | def read_instance_from_h5(self, data_file, index_list, desc=""): |
| 24 | X = list() |
| 25 | y = list() |
| 26 | for idx in tqdm(index_list, desc="Loading data from h5 file." + desc): |
| 27 | X.append(data_file["X"][str(idx)][()].decode("utf-8")) |
| 28 | y.append(data_file["Y"][str(idx)][()].decode("utf-8")) |
| 29 | return {"X": X, "y": y} |
no outgoing calls
no test coverage detected