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
e6f211ca
Unverified
Commit
e6f211ca
authored
Jan 11, 2021
by
Stas Bekman
Committed by
GitHub
Jan 11, 2021
Browse files
[trainer] round numbers in trainer state (#9491)
* round numbers * style * round only on logging
parent
01a16840
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/trainer.py
src/transformers/trainer.py
+2
-2
No files found.
src/transformers/trainer.py
View file @
e6f211ca
...
...
@@ -964,7 +964,7 @@ class Trainer:
# reset tr_loss to zero
tr_loss
-=
tr_loss
logs
[
"loss"
]
=
tr_loss_scalar
/
(
self
.
state
.
global_step
-
self
.
_globalstep_last_logged
)
logs
[
"loss"
]
=
round
(
tr_loss_scalar
/
(
self
.
state
.
global_step
-
self
.
_globalstep_last_logged
)
,
4
)
# backward compatibility for pytorch schedulers
logs
[
"learning_rate"
]
=
(
self
.
lr_scheduler
.
get_last_lr
()[
0
]
...
...
@@ -1168,7 +1168,7 @@ class Trainer:
The values to log.
"""
if
self
.
state
.
epoch
is
not
None
:
logs
[
"epoch"
]
=
self
.
state
.
epoch
logs
[
"epoch"
]
=
round
(
self
.
state
.
epoch
,
2
)
self
.
control
=
self
.
callback_handler
.
on_log
(
self
.
args
,
self
.
state
,
self
.
control
,
logs
)
output
=
{
**
logs
,
**
{
"step"
:
self
.
state
.
global_step
}}
...
...
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