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
d7929899
Commit
d7929899
authored
Nov 14, 2019
by
Lysandre
Browse files
Specify checkpoint in saved file for run_lm_finetuning.py
parent
e18f786c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+3
-3
No files found.
examples/run_lm_finetuning.py
View file @
d7929899
...
@@ -63,10 +63,10 @@ MODEL_CLASSES = {
...
@@ -63,10 +63,10 @@ MODEL_CLASSES = {
class
TextDataset
(
Dataset
):
class
TextDataset
(
Dataset
):
def
__init__
(
self
,
tokenizer
,
file_path
=
'train'
,
block_size
=
512
):
def
__init__
(
self
,
tokenizer
,
args
,
file_path
=
'train'
,
block_size
=
512
):
assert
os
.
path
.
isfile
(
file_path
)
assert
os
.
path
.
isfile
(
file_path
)
directory
,
filename
=
os
.
path
.
split
(
file_path
)
directory
,
filename
=
os
.
path
.
split
(
file_path
)
cached_features_file
=
os
.
path
.
join
(
directory
,
'
cached_lm_'
+
str
(
block_size
)
+
'_'
+
filename
)
cached_features_file
=
os
.
path
.
join
(
directory
,
args
.
model_name_or_path
+
'_
cached_lm_'
+
str
(
block_size
)
+
'_'
+
filename
)
if
os
.
path
.
exists
(
cached_features_file
):
if
os
.
path
.
exists
(
cached_features_file
):
logger
.
info
(
"Loading features from cached file %s"
,
cached_features_file
)
logger
.
info
(
"Loading features from cached file %s"
,
cached_features_file
)
...
@@ -99,7 +99,7 @@ class TextDataset(Dataset):
...
@@ -99,7 +99,7 @@ class TextDataset(Dataset):
def
load_and_cache_examples
(
args
,
tokenizer
,
evaluate
=
False
):
def
load_and_cache_examples
(
args
,
tokenizer
,
evaluate
=
False
):
dataset
=
TextDataset
(
tokenizer
,
file_path
=
args
.
eval_data_file
if
evaluate
else
args
.
train_data_file
,
block_size
=
args
.
block_size
)
dataset
=
TextDataset
(
tokenizer
,
args
,
file_path
=
args
.
eval_data_file
if
evaluate
else
args
.
train_data_file
,
block_size
=
args
.
block_size
)
return
dataset
return
dataset
...
...
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