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
fc87eea2
Commit
fc87eea2
authored
Jun 11, 2018
by
Myle Ott
Browse files
Fix length penalty when combined with --no-early-stop
Co-authored-by:
pmichel31415
<
pmichel@fb.com
>
parent
1fb22af4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
fairseq/sequence_generator.py
fairseq/sequence_generator.py
+4
-10
No files found.
fairseq/sequence_generator.py
View file @
fc87eea2
...
...
@@ -164,7 +164,7 @@ class SequenceGenerator(object):
# finalized one
best_unfinalized_score
=
unfinalized_scores
[
sent
].
max
()
if
self
.
normalize_scores
:
best_unfinalized_score
/=
maxlen
best_unfinalized_score
/=
maxlen
**
self
.
len_penalty
if
worst_finalized
[
sent
][
'score'
]
>=
best_unfinalized_score
:
return
True
return
False
...
...
@@ -479,15 +479,9 @@ class SequenceGenerator(object):
)
# swap buffers
old_tokens
=
tokens
tokens
=
tokens_buf
tokens_buf
=
old_tokens
old_scores
=
scores
scores
=
scores_buf
scores_buf
=
old_scores
old_attn
=
attn
attn
=
attn_buf
attn_buf
=
old_attn
tokens
,
tokens_buf
=
tokens_buf
,
tokens
scores
,
scores_buf
=
scores_buf
,
scores
attn
,
attn_buf
=
attn_buf
,
attn
# reorder incremental state in decoder
reorder_state
=
active_bbsz_idx
...
...
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