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
c53b2ee0
Commit
c53b2ee0
authored
May 08, 2018
by
Myle Ott
Browse files
Remove padding from --score-reference
parent
12a47a64
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
fairseq/sequence_scorer.py
fairseq/sequence_scorer.py
+2
-2
No files found.
fairseq/sequence_scorer.py
View file @
c53b2ee0
...
@@ -31,9 +31,9 @@ class SequenceScorer(object):
...
@@ -31,9 +31,9 @@ class SequenceScorer(object):
if
timer
is
not
None
:
if
timer
is
not
None
:
timer
.
stop
(
s
[
'ntokens'
])
timer
.
stop
(
s
[
'ntokens'
])
for
i
,
id
in
enumerate
(
s
[
'id'
].
data
):
for
i
,
id
in
enumerate
(
s
[
'id'
].
data
):
src
=
s
[
'net_input'
][
'src_tokens'
].
data
[
i
,
:]
# remove padding from ref
# remove padding from ref
ref
=
utils
.
strip_pad
(
s
[
'target'
].
data
[
i
,
:],
self
.
pad
)
src
=
utils
.
strip_pad
(
s
[
'net_input'
][
'src_tokens'
].
data
[
i
,
:],
self
.
pad
)
ref
=
utils
.
strip_pad
(
s
[
'target'
].
data
[
i
,
:],
self
.
pad
)
if
s
[
'target'
]
is
not
None
else
None
tgt_len
=
ref
.
numel
()
tgt_len
=
ref
.
numel
()
pos_scores_i
=
pos_scores
[
i
][:
tgt_len
]
pos_scores_i
=
pos_scores
[
i
][:
tgt_len
]
score_i
=
pos_scores_i
.
sum
()
/
tgt_len
score_i
=
pos_scores_i
.
sum
()
/
tgt_len
...
...
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