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
bd847ce7
Commit
bd847ce7
authored
Oct 23, 2019
by
focox@qq.com
Browse files
fixed the bug raised by "tmp_eval_loss += tmp_eval_loss.item()" when parallelly using multi-gpu.
parent
ef1b8b2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
examples/run_ner.py
examples/run_ner.py
+3
-0
No files found.
examples/run_ner.py
View file @
bd847ce7
...
@@ -210,6 +210,9 @@ def evaluate(args, model, tokenizer, labels, pad_token_label_id, mode, prefix=""
...
@@ -210,6 +210,9 @@ def evaluate(args, model, tokenizer, labels, pad_token_label_id, mode, prefix=""
outputs
=
model
(
**
inputs
)
outputs
=
model
(
**
inputs
)
tmp_eval_loss
,
logits
=
outputs
[:
2
]
tmp_eval_loss
,
logits
=
outputs
[:
2
]
if
args
.
n_gpu
>
1
:
tmp_eval_loss
=
tmp_eval_loss
.
mean
()
# mean() to average on multi-gpu parallel evaluating
eval_loss
+=
tmp_eval_loss
.
item
()
eval_loss
+=
tmp_eval_loss
.
item
()
nb_eval_steps
+=
1
nb_eval_steps
+=
1
if
preds
is
None
:
if
preds
is
None
:
...
...
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