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
63276b76
Unverified
Commit
63276b76
authored
Sep 21, 2020
by
Sylvain Gugger
Committed by
GitHub
Sep 21, 2020
Browse files
Fix #7284 (#7289)
parent
8d464374
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/transformers/data/data_collator.py
src/transformers/data/data_collator.py
+4
-2
No files found.
src/transformers/data/data_collator.py
View file @
63276b76
...
@@ -434,13 +434,15 @@ class DataCollatorForNextSentencePrediction:
...
@@ -434,13 +434,15 @@ class DataCollatorForNextSentencePrediction:
else
:
else
:
input_ids
=
self
.
_tensorize_batch
(
input_ids
)
input_ids
=
self
.
_tensorize_batch
(
input_ids
)
re
turn
{
re
sult
=
{
"input_ids"
:
input_ids
,
"input_ids"
:
input_ids
,
"attention_mask"
:
self
.
_tensorize_batch
(
attention_masks
),
"attention_mask"
:
self
.
_tensorize_batch
(
attention_masks
),
"token_type_ids"
:
self
.
_tensorize_batch
(
segment_ids
),
"token_type_ids"
:
self
.
_tensorize_batch
(
segment_ids
),
"masked_lm_labels"
:
mlm_labels
if
self
.
mlm
else
None
,
"next_sentence_label"
:
torch
.
tensor
(
nsp_labels
),
"next_sentence_label"
:
torch
.
tensor
(
nsp_labels
),
}
}
if
self
.
mlm
:
result
[
"masked_lm_labels"
]
=
mlm_labels
return
result
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
length_of_first
=
examples
[
0
].
size
(
0
)
length_of_first
=
examples
[
0
].
size
(
0
)
...
...
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