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
b72f9d34
Commit
b72f9d34
authored
Dec 10, 2019
by
LysandreJik
Browse files
Correct index in script
parent
ec6fb25c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+1
-1
No files found.
examples/run_lm_finetuning.py
View file @
b72f9d34
...
...
@@ -150,7 +150,7 @@ def mask_tokens(inputs, tokenizer, args):
special_tokens_mask
=
[
tokenizer
.
get_special_tokens_mask
(
val
,
already_has_special_tokens
=
True
)
for
val
in
labels
.
tolist
()]
probability_matrix
.
masked_fill_
(
torch
.
tensor
(
special_tokens_mask
,
dtype
=
torch
.
bool
),
value
=
0.0
)
masked_indices
=
torch
.
bernoulli
(
probability_matrix
).
bool
()
labels
[
~
masked_indices
]
=
-
1
# We only compute loss on masked tokens
labels
[
~
masked_indices
]
=
-
1
00
# We only compute loss on masked tokens
# 80% of the time, we replace masked input tokens with tokenizer.mask_token ([MASK])
indices_replaced
=
torch
.
bernoulli
(
torch
.
full
(
labels
.
shape
,
0.8
)).
bool
()
&
masked_indices
...
...
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