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
ba973342
Unverified
Commit
ba973342
authored
Nov 05, 2019
by
Thomas Wolf
Committed by
GitHub
Nov 05, 2019
Browse files
Merge pull request #1553 from WilliamTambellini/timeSquadInference
Add speed log to examples/run_squad.py
parents
237fad33
0919389d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
examples/run_squad.py
examples/run_squad.py
+5
-0
No files found.
examples/run_squad.py
View file @
ba973342
...
...
@@ -22,6 +22,7 @@ import logging
import
os
import
random
import
glob
import
timeit
import
numpy
as
np
import
torch
...
...
@@ -221,6 +222,7 @@ def evaluate(args, model, tokenizer, prefix=""):
logger
.
info
(
" Num examples = %d"
,
len
(
dataset
))
logger
.
info
(
" Batch size = %d"
,
args
.
eval_batch_size
)
all_results
=
[]
start_time
=
timeit
.
default_timer
()
for
batch
in
tqdm
(
eval_dataloader
,
desc
=
"Evaluating"
):
model
.
eval
()
batch
=
tuple
(
t
.
to
(
args
.
device
)
for
t
in
batch
)
...
...
@@ -253,6 +255,9 @@ def evaluate(args, model, tokenizer, prefix=""):
end_logits
=
to_list
(
outputs
[
1
][
i
]))
all_results
.
append
(
result
)
evalTime
=
timeit
.
default_timer
()
-
start_time
logger
.
info
(
" Evaluation done in total %f secs (%f sec per example)"
,
evalTime
,
evalTime
/
len
(
dataset
))
# Compute predictions
output_prediction_file
=
os
.
path
.
join
(
args
.
output_dir
,
"predictions_{}.json"
.
format
(
prefix
))
output_nbest_file
=
os
.
path
.
join
(
args
.
output_dir
,
"nbest_predictions_{}.json"
.
format
(
prefix
))
...
...
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