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
4e0cba10
Unverified
Commit
4e0cba10
authored
Jan 14, 2019
by
Thomas Wolf
Committed by
GitHub
Jan 14, 2019
Browse files
Merge pull request #191 from nhatchan/20190113_py35_finetune
lm_finetuning compatibility with Python 3.5
parents
c9445565
6c65cb24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+6
-6
No files found.
examples/run_lm_finetuning.py
View file @
4e0cba10
...
@@ -139,11 +139,11 @@ class BERTDataset(Dataset):
...
@@ -139,11 +139,11 @@ class BERTDataset(Dataset):
# transform sample to features
# transform sample to features
cur_features
=
convert_example_to_features
(
cur_example
,
self
.
seq_len
,
self
.
tokenizer
)
cur_features
=
convert_example_to_features
(
cur_example
,
self
.
seq_len
,
self
.
tokenizer
)
cur_tensors
=
{
"input_ids"
:
torch
.
tensor
(
cur_features
.
input_ids
),
cur_tensors
=
(
torch
.
tensor
(
cur_features
.
input_ids
),
"input_mask"
:
torch
.
tensor
(
cur_features
.
input_mask
),
torch
.
tensor
(
cur_features
.
input_mask
),
"segment_ids"
:
torch
.
tensor
(
cur_features
.
segment_ids
),
torch
.
tensor
(
cur_features
.
segment_ids
),
"lm_label_ids"
:
torch
.
tensor
(
cur_features
.
lm_label_ids
),
torch
.
tensor
(
cur_features
.
lm_label_ids
),
"is_next"
:
torch
.
tensor
(
cur_features
.
is_next
)
}
torch
.
tensor
(
cur_features
.
is_next
)
)
return
cur_tensors
return
cur_tensors
...
@@ -592,7 +592,7 @@ def main():
...
@@ -592,7 +592,7 @@ def main():
tr_loss
=
0
tr_loss
=
0
nb_tr_examples
,
nb_tr_steps
=
0
,
0
nb_tr_examples
,
nb_tr_steps
=
0
,
0
for
step
,
batch
in
enumerate
(
tqdm
(
train_dataloader
,
desc
=
"Iteration"
)):
for
step
,
batch
in
enumerate
(
tqdm
(
train_dataloader
,
desc
=
"Iteration"
)):
batch
=
tuple
(
t
.
to
(
device
)
for
t
in
batch
.
values
()
)
batch
=
tuple
(
t
.
to
(
device
)
for
t
in
batch
)
input_ids
,
input_mask
,
segment_ids
,
lm_label_ids
,
is_next
=
batch
input_ids
,
input_mask
,
segment_ids
,
lm_label_ids
,
is_next
=
batch
loss
=
model
(
input_ids
,
segment_ids
,
input_mask
,
lm_label_ids
,
is_next
)
loss
=
model
(
input_ids
,
segment_ids
,
input_mask
,
lm_label_ids
,
is_next
)
if
n_gpu
>
1
:
if
n_gpu
>
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