"...git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "ceb89df4e195b91cecc66b2f7d5d585bd0724856"
Commit f671997e authored by Lysandre's avatar Lysandre
Browse files

Interface with TFDS

parent bd41e829
...@@ -246,16 +246,24 @@ class SquadProcessor(DataProcessor): ...@@ -246,16 +246,24 @@ class SquadProcessor(DataProcessor):
dev_file = None dev_file = None
def get_example_from_tensor_dict(self, tensor_dict): def get_example_from_tensor_dict(self, tensor_dict):
"""See base class."""
return NewSquadExample( return NewSquadExample(
tensor_dict['id'].numpy(), tensor_dict['id'].numpy().decode("utf-8"),
tensor_dict['question'].numpy().decode('utf-8'), tensor_dict['question'].numpy().decode('utf-8'),
tensor_dict['context'].numpy().decode('utf-8'), tensor_dict['context'].numpy().decode('utf-8'),
tensor_dict['answers']['text'].numpy().decode('utf-8'), tensor_dict['answers']['text'][0].numpy().decode('utf-8'),
tensor_dict['answers']['answers_start'].numpy().decode('utf-8'), tensor_dict['answers']['answer_start'][0].numpy(),
tensor_dict['title'].numpy().decode('utf-8') tensor_dict['title'].numpy().decode('utf-8')
) )
def get_examples_from_dataset(self, dataset):
"""See base class."""
examples = []
for tensor_dict in tqdm(dataset):
examples.append(self.get_example_from_tensor_dict(tensor_dict))
return examples
def get_train_examples(self, data_dir, only_first=None): def get_train_examples(self, data_dir, only_first=None):
"""See base class.""" """See base class."""
if self.train_file is None: if self.train_file is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment