MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / instance_reader

Method instance_reader

NLP/NAACL2019-MPM/reader.py:156–171  ·  view source on GitHub ↗

Process sinle example and return.

()

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 3

convert_exampleMethod · 0.95
get_labelsMethod · 0.95
generate_instanceMethod · 0.95

Tested by

no test coverage detected