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
801aaa55
Commit
801aaa55
authored
Jan 17, 2020
by
Julien Chaumond
Browse files
make style
parent
56d4ba8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+5
-5
No files found.
examples/run_lm_finetuning.py
View file @
801aaa55
...
@@ -228,8 +228,10 @@ def train(args, train_dataset, model: PreTrainedModel, tokenizer: PreTrainedToke
...
@@ -228,8 +228,10 @@ def train(args, train_dataset, model: PreTrainedModel, tokenizer: PreTrainedToke
)
)
# Check if saved optimizer or scheduler states exist
# Check if saved optimizer or scheduler states exist
if
args
.
model_name_or_path
and
os
.
path
.
isfile
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"optimizer.pt"
))
and
os
.
path
.
isfile
(
if
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"scheduler.pt"
)
args
.
model_name_or_path
and
os
.
path
.
isfile
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"optimizer.pt"
))
and
os
.
path
.
isfile
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"scheduler.pt"
))
):
):
# Load in optimizer and scheduler states
# Load in optimizer and scheduler states
optimizer
.
load_state_dict
(
torch
.
load
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"optimizer.pt"
)))
optimizer
.
load_state_dict
(
torch
.
load
(
os
.
path
.
join
(
args
.
model_name_or_path
,
"optimizer.pt"
)))
...
@@ -587,9 +589,7 @@ def main():
...
@@ -587,9 +589,7 @@ def main():
if
args
.
should_continue
:
if
args
.
should_continue
:
sorted_checkpoints
=
_sorted_checkpoints
(
args
)
sorted_checkpoints
=
_sorted_checkpoints
(
args
)
if
len
(
sorted_checkpoints
)
==
0
:
if
len
(
sorted_checkpoints
)
==
0
:
raise
ValueError
(
raise
ValueError
(
"Used --should_continue but no checkpoint was found in --output_dir."
)
"Used --should_continue but no checkpoint was found in --output_dir."
)
else
:
else
:
args
.
model_name_or_path
=
sorted_checkpoints
[
-
1
]
args
.
model_name_or_path
=
sorted_checkpoints
[
-
1
]
...
...
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