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
7e86e30c
Unverified
Commit
7e86e30c
authored
Feb 12, 2018
by
Myle Ott
Committed by
GitHub
Feb 12, 2018
Browse files
Allow larger maxlen (fixes #100) (#101)
parent
9a951216
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
fairseq/sequence_generator.py
fairseq/sequence_generator.py
+3
-2
No files found.
fairseq/sequence_generator.py
View file @
7e86e30c
...
@@ -17,7 +17,7 @@ from fairseq.models import FairseqIncrementalDecoder
...
@@ -17,7 +17,7 @@ from fairseq.models import FairseqIncrementalDecoder
class
SequenceGenerator
(
object
):
class
SequenceGenerator
(
object
):
def
__init__
(
self
,
models
,
beam_size
=
1
,
minlen
=
1
,
maxlen
=
200
,
def
__init__
(
self
,
models
,
beam_size
=
1
,
minlen
=
1
,
maxlen
=
None
,
stop_early
=
True
,
normalize_scores
=
True
,
len_penalty
=
1
,
stop_early
=
True
,
normalize_scores
=
True
,
len_penalty
=
1
,
unk_penalty
=
0
,
retain_dropout
=
False
):
unk_penalty
=
0
,
retain_dropout
=
False
):
"""Generates translations of a given source sentence.
"""Generates translations of a given source sentence.
...
@@ -40,7 +40,8 @@ class SequenceGenerator(object):
...
@@ -40,7 +40,8 @@ class SequenceGenerator(object):
self
.
vocab_size
=
len
(
models
[
0
].
dst_dict
)
self
.
vocab_size
=
len
(
models
[
0
].
dst_dict
)
self
.
beam_size
=
beam_size
self
.
beam_size
=
beam_size
self
.
minlen
=
minlen
self
.
minlen
=
minlen
self
.
maxlen
=
min
(
maxlen
,
*
[
m
.
max_decoder_positions
()
for
m
in
self
.
models
])
max_decoder_len
=
min
([
m
.
max_decoder_positions
()
for
m
in
self
.
models
])
self
.
maxlen
=
max_decoder_len
if
maxlen
is
None
else
min
(
maxlen
,
max_decoder_len
)
self
.
stop_early
=
stop_early
self
.
stop_early
=
stop_early
self
.
normalize_scores
=
normalize_scores
self
.
normalize_scores
=
normalize_scores
self
.
len_penalty
=
len_penalty
self
.
len_penalty
=
len_penalty
...
...
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