From 6f54c85cec67ad7edda41f7a3e3e4008347be774 Mon Sep 17 00:00:00 2001 From: Zeyu Chen Date: Tue, 9 Apr 2019 22:56:33 +0800 Subject: [PATCH] add docstring demo --- paddlehub/dataset/dataset.py | 25 ------------------------- paddlehub/finetune/task.py | 11 +++++++++-- paddlehub/reader/nlp_reader.py | 24 ------------------------ 3 files changed, 9 insertions(+), 51 deletions(-) diff --git a/paddlehub/dataset/dataset.py b/paddlehub/dataset/dataset.py index aefd698e..2b1577cf 100644 --- a/paddlehub/dataset/dataset.py +++ b/paddlehub/dataset/dataset.py @@ -13,31 +13,6 @@ # limitations under the License. -class InputExample(object): - """ - Input data structure of BERT/ERNIE, can satisfy single sequence task like - text classification, sequence lableing; Sequence pair task like dialog - task. - """ - - def __init__(self, guid, text_a, text_b=None, label=None): - """Constructs a InputExample. - - Args: - guid: Unique id for the example. - text_a: string. The untokenized text of the first sequence. For single - sequence tasks, only this sequence must be specified. - text_b: (Optional) string. The untokenized text of the second sequence. - Only must be specified for sequence pair tasks. - label: (Optional) string. The label of the example. This should be - specified for train and dev examples, but not for test examples. - """ - self.guid = guid - self.text_a = text_a - self.text_b = text_b - self.label = label - - class HubDataset(object): def get_train_examples(self): raise NotImplementedError() diff --git a/paddlehub/finetune/task.py b/paddlehub/finetune/task.py index db2a4b32..a6dd964b 100644 --- a/paddlehub/finetune/task.py +++ b/paddlehub/finetune/task.py @@ -109,8 +109,15 @@ def create_img_classification_task(feature, num_classes, hidden_units=None): """ - Append a multi-layer perceptron classifier for binary classification base - on input feature + Create the transfer learning task for image classification. + Args: + feature: + + Return: + Task + + Raise: + None """ cls_feats = feature # append fully connected layer according to hidden_units diff --git a/paddlehub/reader/nlp_reader.py b/paddlehub/reader/nlp_reader.py index abed54c0..1e0ae39f 100644 --- a/paddlehub/reader/nlp_reader.py +++ b/paddlehub/reader/nlp_reader.py @@ -52,12 +52,6 @@ class BaseReader(object): self.current_epoch = 0 self.num_examples = 0 - # if label_map_config: - # with open(label_map_config) as f: - # self.label_map = json.load(f) - # else: - # self.label_map = None - self.num_examples = {'train': -1, 'dev': -1, 'test': -1} def get_train_examples(self): @@ -164,20 +158,6 @@ class BaseReader(object): else: label_id = example.label - # Record = namedtuple( - # 'Record', - # ['token_ids', 'text_type_ids', 'position_ids', 'label_id', 'qid']) - - # qid = None - # if "qid" in example._fields: - # qid = example.qid - - # record = Record( - # token_ids=token_ids, - # text_type_ids=text_type_ids, - # position_ids=position_ids, - # label_id=label_id, - # qid=qid) Record = namedtuple( 'Record', ['token_ids', 'text_type_ids', 'position_ids', 'label_id']) @@ -211,10 +191,6 @@ class BaseReader(object): if batch_records: yield self._pad_batch_records(batch_records) - # def get_num_examples(self, input_file): - # examples = self._read_tsv(input_file) - # return len(examples) - def get_num_examples(self, phase): """Get number of examples for train, dev or test.""" if phase not in ['train', 'val', 'dev', 'test']: -- GitLab