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
1ebfeb79
Commit
1ebfeb79
authored
Feb 04, 2020
by
Lysandre
Browse files
Cast to long when masking tokens
parent
9c67196b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
0 deletions
+1
-0
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+1
-0
No files found.
examples/run_lm_finetuning.py
View file @
1ebfeb79
...
@@ -195,6 +195,7 @@ def _rotate_checkpoints(args, checkpoint_prefix="checkpoint", use_mtime=False) -
...
@@ -195,6 +195,7 @@ def _rotate_checkpoints(args, checkpoint_prefix="checkpoint", use_mtime=False) -
def
mask_tokens
(
inputs
:
torch
.
Tensor
,
tokenizer
:
PreTrainedTokenizer
,
args
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]:
def
mask_tokens
(
inputs
:
torch
.
Tensor
,
tokenizer
:
PreTrainedTokenizer
,
args
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]:
""" Prepare masked tokens inputs/labels for masked language modeling: 80% MASK, 10% random, 10% original. """
""" Prepare masked tokens inputs/labels for masked language modeling: 80% MASK, 10% random, 10% original. """
inputs
=
inputs
.
clone
().
type
(
dtype
=
torch
.
long
)
labels
=
inputs
.
clone
()
labels
=
inputs
.
clone
()
# We sample a few tokens in each sequence for masked-LM training (with probability args.mlm_probability defaults to 0.15 in Bert/RoBERTa)
# We sample a few tokens in each sequence for masked-LM training (with probability args.mlm_probability defaults to 0.15 in Bert/RoBERTa)
probability_matrix
=
torch
.
full
(
labels
.
shape
,
args
.
mlm_probability
)
probability_matrix
=
torch
.
full
(
labels
.
shape
,
args
.
mlm_probability
)
...
...
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