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
6e4c8f68
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "abb7d1ff6dc7e54bd029eb8703fb12caf24baf38"
Unverified
Commit
6e4c8f68
authored
Oct 11, 2021
by
Jungwoo Park
Committed by
GitHub
Oct 11, 2021
Browse files
change to apply `pad_to_multiple_of` to labels (#13949)
parent
dca67968
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
src/transformers/data/data_collator.py
src/transformers/data/data_collator.py
+7
-0
No files found.
src/transformers/data/data_collator.py
View file @
6e4c8f68
...
@@ -534,6 +534,13 @@ class DataCollatorForSeq2Seq:
...
@@ -534,6 +534,13 @@ class DataCollatorForSeq2Seq:
# same length to return tensors.
# same length to return tensors.
if
labels
is
not
None
:
if
labels
is
not
None
:
max_label_length
=
max
(
len
(
l
)
for
l
in
labels
)
max_label_length
=
max
(
len
(
l
)
for
l
in
labels
)
if
self
.
pad_to_multiple_of
is
not
None
:
max_label_length
=
(
(
max_label_length
+
self
.
pad_to_multiple_of
-
1
)
//
self
.
pad_to_multiple_of
*
self
.
pad_to_multiple_of
)
padding_side
=
self
.
tokenizer
.
padding_side
padding_side
=
self
.
tokenizer
.
padding_side
for
feature
in
features
:
for
feature
in
features
:
remainder
=
[
self
.
label_pad_token_id
]
*
(
max_label_length
-
len
(
feature
[
"labels"
]))
remainder
=
[
self
.
label_pad_token_id
]
*
(
max_label_length
-
len
(
feature
[
"labels"
]))
...
...
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