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
25e1af36
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "8ac840ff8758fb242e3e89cbc809366165ccf960"
Unverified
Commit
25e1af36
authored
Apr 14, 2021
by
Sylvain Gugger
Committed by
GitHub
Apr 14, 2021
Browse files
Fix #10128 (#11248)
parent
63ca4023
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/trainer_pt_utils.py
src/transformers/trainer_pt_utils.py
+1
-1
No files found.
src/transformers/trainer_pt_utils.py
View file @
25e1af36
...
@@ -72,7 +72,7 @@ def torch_pad_and_concatenate(tensor1, tensor2, padding_index=-100):
...
@@ -72,7 +72,7 @@ def torch_pad_and_concatenate(tensor1, tensor2, padding_index=-100):
def
numpy_pad_and_concatenate
(
array1
,
array2
,
padding_index
=-
100
):
def
numpy_pad_and_concatenate
(
array1
,
array2
,
padding_index
=-
100
):
"""Concatenates `array1` and `array2` on first axis, applying padding on the second if necessary."""
"""Concatenates `array1` and `array2` on first axis, applying padding on the second if necessary."""
if
len
(
array1
.
shape
)
==
1
or
array1
.
shape
[
1
]
==
array2
.
shape
[
1
]:
if
len
(
array1
.
shape
)
==
1
or
array1
.
shape
[
1
]
==
array2
.
shape
[
1
]:
return
np
.
concatenate
((
array1
,
array2
),
dim
=
0
)
return
np
.
concatenate
((
array1
,
array2
),
axis
=
0
)
# Let's figure out the new shape
# Let's figure out the new shape
new_shape
=
(
array1
.
shape
[
0
]
+
array2
.
shape
[
0
],
max
(
array1
.
shape
[
1
],
array2
.
shape
[
1
]))
+
array1
.
shape
[
2
:]
new_shape
=
(
array1
.
shape
[
0
]
+
array2
.
shape
[
0
],
max
(
array1
.
shape
[
1
],
array2
.
shape
[
1
]))
+
array1
.
shape
[
2
:]
...
...
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