Process sinle example and return.
()
| 154 | "Unknown phase, which should be in ['train', 'dev', 'test'].") |
| 155 | |
| 156 | def instance_reader(): |
| 157 | """Process sinle example and return.""" |
| 158 | for epoch_index in range(epoch): |
| 159 | if shuffle: |
| 160 | np.random.shuffle(examples) |
| 161 | if phase == 'train': |
| 162 | self.current_train_epoch = epoch_index |
| 163 | for (index, example) in enumerate(examples): |
| 164 | if phase == 'train': |
| 165 | self.current_train_example = index + 1 |
| 166 | feature = self.convert_example( |
| 167 | index, example, |
| 168 | self.get_labels(), self.max_seq_len, self.tokenizer) |
| 169 | |
| 170 | instance = self.generate_instance(feature) |
| 171 | yield instance |
| 172 | |
| 173 | def batch_reader(reader, batch_size, in_tokens): |
| 174 | """Generate batch data and return.""" |
nothing calls this directly
no test coverage detected