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
5d390e9e
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "5ea2595ecde9a89079d4d289bc65dc5f8dc02ef6"
Unverified
Commit
5d390e9e
authored
Oct 06, 2021
by
Anton Lozhkov
Committed by
GitHub
Oct 06, 2021
Browse files
Fix nan-loss condition (#13911)
parent
8f2c07d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
src/transformers/trainer.py
src/transformers/trainer.py
+7
-4
No files found.
src/transformers/trainer.py
View file @
5d390e9e
...
@@ -1315,10 +1315,13 @@ class Trainer:
...
@@ -1315,10 +1315,13 @@ class Trainer:
else
:
else
:
tr_loss_step
=
self
.
training_step
(
model
,
inputs
)
tr_loss_step
=
self
.
training_step
(
model
,
inputs
)
if
args
.
logging_nan_inf_filter
and
not
is_torch_tpu_available
():
if
(
if
torch
.
isnan
(
tr_loss_step
)
or
torch
.
isinf
(
tr_loss_step
):
args
.
logging_nan_inf_filter
# if loss is nan or inf simply add the average of previous logged losses
and
not
is_torch_tpu_available
()
tr_loss
+=
tr_loss
/
(
1
+
self
.
state
.
global_step
-
self
.
_globalstep_last_logged
)
and
(
torch
.
isnan
(
tr_loss_step
)
or
torch
.
isinf
(
tr_loss_step
))
):
# if loss is nan or inf simply add the average of previous logged losses
tr_loss
+=
tr_loss
/
(
1
+
self
.
state
.
global_step
-
self
.
_globalstep_last_logged
)
else
:
else
:
tr_loss
+=
tr_loss_step
tr_loss
+=
tr_loss_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