diff --git a/BERT/model/bert.py b/BERT/model/bert.py index e698dda2979be539fcb30e6618fa0e4ff6e7e92a..c17803caed17e81fafd55f9b9ae9f2b539f9f39c 100644 --- a/BERT/model/bert.py +++ b/BERT/model/bert.py @@ -115,7 +115,7 @@ class BertModel(object): self_attn_mask = fluid.layers.matmul( x=input_mask, y=input_mask, transpose_y=True) self_attn_mask = fluid.layers.scale( - x=self_attn_mask, scale=1000.0, bias=-1.0, bias_after_scale=False) + x=self_attn_mask, scale=10000.0, bias=-1.0, bias_after_scale=False) n_head_self_attn_mask = fluid.layers.stack( x=[self_attn_mask] * self._n_head, axis=1) n_head_self_attn_mask.stop_gradient = True diff --git a/ERNIE/finetune/sequence_label.py b/ERNIE/finetune/sequence_label.py index 572928d58e867340adaf6d4eee915a3c4a10356e..3c5163ecd56af57334e9f7f49acc259309cc8994 100644 --- a/ERNIE/finetune/sequence_label.py +++ b/ERNIE/finetune/sequence_label.py @@ -156,17 +156,19 @@ def chunk_eval(np_labels, np_infers, np_lens, tag_num, dev_count=1): infer_index = 0 label_index = 0 - while label_index < len(label_chunks) and infer_index < len( - infer_chunks): - if infer_chunks[infer_index]["st"] < label_chunks[label_index][ - "st"]: + while label_index < len(label_chunks) \ + and infer_index < len(infer_chunks): + if infer_chunks[infer_index]["st"] \ + < label_chunks[label_index]["st"]: infer_index += 1 - elif infer_chunks[infer_index]["st"] > label_chunks[ - label_index]["st"]: + elif infer_chunks[infer_index]["st"] \ + > label_chunks[label_index]["st"]: label_index += 1 else: - if infer_chunks[infer_index]["en"] == label_chunks[label_index]["en"] and \ - infer_chunks[infer_index]["type"] == label_chunks[label_index]["type"]: + if infer_chunks[infer_index]["en"] \ + == label_chunks[label_index]["en"] \ + and infer_chunks[infer_index]["type"] \ + == label_chunks[label_index]["type"]: num_correct += 1 infer_index += 1 diff --git a/ERNIE/model/ernie.py b/ERNIE/model/ernie.py index 7355676544c80e249286f0f0a2b298dda5e878cf..3ccfb72a43b8385dc4f5e92ec2a446d40c384788 100644 --- a/ERNIE/model/ernie.py +++ b/ERNIE/model/ernie.py @@ -115,7 +115,7 @@ class ErnieModel(object): x=input_mask, y=input_mask, transpose_y=True) self_attn_mask = fluid.layers.scale( - x=self_attn_mask, scale=1000.0, bias=-1.0, bias_after_scale=False) + x=self_attn_mask, scale=10000.0, bias=-1.0, bias_after_scale=False) n_head_self_attn_mask = fluid.layers.stack( x=[self_attn_mask] * self._n_head, axis=1) n_head_self_attn_mask.stop_gradient = True