Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
5d3b8daa
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "64c06df325c9b59a8d3aae7670c85d9977c517bf"
Commit
5d3b8daa
authored
Nov 22, 2019
by
manansanghi
Committed by
Lysandre Debut
Nov 25, 2019
Browse files
Minor bug fixes on run_ner.py
parent
aa92a184
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
examples/run_ner.py
examples/run_ner.py
+2
-2
No files found.
examples/run_ner.py
View file @
5d3b8daa
...
@@ -127,7 +127,7 @@ def train(args, train_dataset, model, tokenizer, labels, pad_token_label_id):
...
@@ -127,7 +127,7 @@ def train(args, train_dataset, model, tokenizer, labels, pad_token_label_id):
"attention_mask"
:
batch
[
1
],
"attention_mask"
:
batch
[
1
],
"labels"
:
batch
[
3
]}
"labels"
:
batch
[
3
]}
if
args
.
model_type
!=
"distilbert"
:
if
args
.
model_type
!=
"distilbert"
:
inputs
[
"token_type_ids"
]
:
batch
[
2
]
if
args
.
model_type
in
[
"bert"
,
"xlnet"
]
else
None
# XLM and RoBERTa don"t use segment_ids
inputs
[
"token_type_ids"
]
=
batch
[
2
]
if
args
.
model_type
in
[
"bert"
,
"xlnet"
]
else
None
# XLM and RoBERTa don"t use segment_ids
outputs
=
model
(
**
inputs
)
outputs
=
model
(
**
inputs
)
loss
=
outputs
[
0
]
# model outputs are always tuple in pytorch-transformers (see doc)
loss
=
outputs
[
0
]
# model outputs are always tuple in pytorch-transformers (see doc)
...
@@ -217,7 +217,7 @@ def evaluate(args, model, tokenizer, labels, pad_token_label_id, mode, prefix=""
...
@@ -217,7 +217,7 @@ def evaluate(args, model, tokenizer, labels, pad_token_label_id, mode, prefix=""
"attention_mask"
:
batch
[
1
],
"attention_mask"
:
batch
[
1
],
"labels"
:
batch
[
3
]}
"labels"
:
batch
[
3
]}
if
args
.
model_type
!=
"distilbert"
:
if
args
.
model_type
!=
"distilbert"
:
inputs
[
"token_type_ids"
]
:
batch
[
2
]
if
args
.
model_type
in
[
"bert"
,
"xlnet"
]
else
None
# XLM and RoBERTa don"t use segment_ids
inputs
[
"token_type_ids"
]
=
batch
[
2
]
if
args
.
model_type
in
[
"bert"
,
"xlnet"
]
else
None
# XLM and RoBERTa don"t use segment_ids
outputs
=
model
(
**
inputs
)
outputs
=
model
(
**
inputs
)
tmp_eval_loss
,
logits
=
outputs
[:
2
]
tmp_eval_loss
,
logits
=
outputs
[:
2
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment