Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
6b850b67
Unverified
Commit
6b850b67
authored
Dec 18, 2020
by
Stas Bekman
Committed by
GitHub
Dec 18, 2020
Browse files
[run_glue] add speed metrics (#9198)
* add speed metrics * suggestions
parent
3ff5e895
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
examples/text-classification/run_glue.py
examples/text-classification/run_glue.py
+15
-2
No files found.
examples/text-classification/run_glue.py
View file @
6b850b67
...
...
@@ -350,11 +350,24 @@ def main():
# Training
if
training_args
.
do_train
:
trainer
.
train
(
train_result
=
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
)
metrics
=
train_result
.
metrics
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
output_train_file
=
os
.
path
.
join
(
training_args
.
output_dir
,
"train_results.txt"
)
if
trainer
.
is_world_process_zero
():
with
open
(
output_train_file
,
"w"
)
as
writer
:
logger
.
info
(
"***** Train results *****"
)
for
key
,
value
in
sorted
(
metrics
.
items
()):
logger
.
info
(
f
"
{
key
}
=
{
value
}
"
)
writer
.
write
(
f
"
{
key
}
=
{
value
}
\n
"
)
# Need to save the state, since Trainer.save_model saves only the tokenizer with the model
trainer
.
state
.
save_to_json
(
os
.
path
.
join
(
training_args
.
output_dir
,
"trainer_state.json"
))
# Evaluation
eval_results
=
{}
if
training_args
.
do_eval
:
...
...
@@ -374,7 +387,7 @@ def main():
if
trainer
.
is_world_process_zero
():
with
open
(
output_eval_file
,
"w"
)
as
writer
:
logger
.
info
(
f
"***** Eval results
{
task
}
*****"
)
for
key
,
value
in
eval_result
.
items
():
for
key
,
value
in
sorted
(
eval_result
.
items
()
)
:
logger
.
info
(
f
"
{
key
}
=
{
value
}
"
)
writer
.
write
(
f
"
{
key
}
=
{
value
}
\n
"
)
...
...
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