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
b91cff5a
Unverified
Commit
b91cff5a
authored
Oct 16, 2023
by
Jintao
Committed by
GitHub
Oct 16, 2023
Browse files
fix resume_from_checkpoint bug (#26739)
* fix resume_from_checkpoint bug * update code
parent
a5f5568d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/trainer.py
src/transformers/trainer.py
+4
-1
No files found.
src/transformers/trainer.py
View file @
b91cff5a
...
@@ -2862,7 +2862,10 @@ class Trainer:
...
@@ -2862,7 +2862,10 @@ class Trainer:
checkpoints_sorted
=
sorted
(
ordering_and_checkpoint_path
)
checkpoints_sorted
=
sorted
(
ordering_and_checkpoint_path
)
checkpoints_sorted
=
[
checkpoint
[
1
]
for
checkpoint
in
checkpoints_sorted
]
checkpoints_sorted
=
[
checkpoint
[
1
]
for
checkpoint
in
checkpoints_sorted
]
# Make sure we don't delete the best model.
# Make sure we don't delete the best model.
if
self
.
state
.
best_model_checkpoint
is
not
None
:
if
(
self
.
state
.
best_model_checkpoint
is
not
None
and
str
(
Path
(
self
.
state
.
best_model_checkpoint
))
in
checkpoints_sorted
):
best_model_index
=
checkpoints_sorted
.
index
(
str
(
Path
(
self
.
state
.
best_model_checkpoint
)))
best_model_index
=
checkpoints_sorted
.
index
(
str
(
Path
(
self
.
state
.
best_model_checkpoint
)))
for
i
in
range
(
best_model_index
,
len
(
checkpoints_sorted
)
-
2
):
for
i
in
range
(
best_model_index
,
len
(
checkpoints_sorted
)
-
2
):
checkpoints_sorted
[
i
],
checkpoints_sorted
[
i
+
1
]
=
checkpoints_sorted
[
i
+
1
],
checkpoints_sorted
[
i
]
checkpoints_sorted
[
i
],
checkpoints_sorted
[
i
+
1
]
=
checkpoints_sorted
[
i
+
1
],
checkpoints_sorted
[
i
]
...
...
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