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
OpenDAS
Fairseq
Commits
5637d54e
Commit
5637d54e
authored
Dec 22, 2017
by
Myle Ott
Browse files
Minor fix for strip_pad functions
parent
a4f86a89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
fairseq/utils.py
fairseq/utils.py
+2
-2
No files found.
fairseq/utils.py
View file @
5637d54e
...
@@ -236,11 +236,11 @@ def post_process_prediction(hypo_tokens, src_str, alignment, align_dict, dst_dic
...
@@ -236,11 +236,11 @@ def post_process_prediction(hypo_tokens, src_str, alignment, align_dict, dst_dic
def
lstrip_pad
(
tensor
,
pad
):
def
lstrip_pad
(
tensor
,
pad
):
return
tensor
[
tensor
.
eq
(
pad
).
sum
():]
return
tensor
[
tensor
.
eq
(
pad
).
long
().
sum
():]
def
rstrip_pad
(
tensor
,
pad
):
def
rstrip_pad
(
tensor
,
pad
):
strip
=
tensor
.
eq
(
pad
).
sum
()
strip
=
tensor
.
eq
(
pad
).
long
().
sum
()
if
strip
>
0
:
if
strip
>
0
:
return
tensor
[:
-
strip
]
return
tensor
[:
-
strip
]
return
tensor
return
tensor
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