提交 6f54c85c 编写于 作者: Z Zeyu Chen

add docstring demo

上级 36f0890d
......@@ -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()
......
......@@ -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
......
......@@ -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']:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册