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
69629c4f
Commit
69629c4f
authored
Oct 07, 2019
by
jinoobaek-qz
Committed by
Lysandre Debut
Oct 09, 2019
Browse files
Improve naming and only do regex when necessary
parent
bf34a252
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+8
-8
No files found.
examples/run_lm_finetuning.py
View file @
69629c4f
...
...
@@ -117,16 +117,16 @@ def _rotate_checkpoints(args, checkpoint_prefix, use_mtime=False):
if
len
(
glob_checkpoints
)
<=
args
.
save_total_limit
:
return
checkpoint
s_sorted
=
[]
ordering_and_
checkpoint
_path
=
[]
for
path
in
glob_checkpoints
:
regex_match
=
re
.
match
(
'.*{}-([0-9]+)'
.
format
(
checkpoint_prefix
),
path
)
if
regex_match
and
regex_match
.
groups
():
if
use_mtime
:
checkpoint
s_sorted
.
append
((
os
.
path
.
getmtime
(
path
),
path
))
ordering_and_
checkpoint
_path
.
append
((
os
.
path
.
getmtime
(
path
),
path
))
else
:
checkpoints_sorted
.
append
((
int
(
regex_match
.
groups
()[
0
]),
path
))
regex_match
=
re
.
match
(
'.*{}-([0-9]+)'
.
format
(
checkpoint_prefix
),
path
)
if
regex_match
and
regex_match
.
groups
():
ordering_and_checkpoint_path
.
append
((
int
(
regex_match
.
groups
()[
0
]),
path
))
checkpoints_sorted
=
sorted
(
checkpoint
s_sorted
)
checkpoints_sorted
=
sorted
(
ordering_and_
checkpoint
_path
)
checkpoints_sorted
=
[
checkpoint
[
1
]
for
checkpoint
in
checkpoints_sorted
]
number_of_checkpoints_to_delete
=
max
(
0
,
len
(
checkpoints_sorted
)
-
args
.
save_total_limit
)
checkpoints_to_be_deleted
=
checkpoints_sorted
[:
number_of_checkpoints_to_delete
]
...
...
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