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
48631f7a
Commit
48631f7a
authored
Sep 27, 2017
by
Myle Ott
Browse files
Allow --max-len-a to be a float
parent
813352e1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
fairseq/options.py
fairseq/options.py
+3
-3
fairseq/sequence_generator.py
fairseq/sequence_generator.py
+2
-2
No files found.
fairseq/options.py
View file @
48631f7a
...
...
@@ -85,11 +85,11 @@ def add_generation_args(parser):
help
=
'beam size'
)
group
.
add_argument
(
'--nbest'
,
default
=
1
,
type
=
int
,
metavar
=
'N'
,
help
=
'number of hypotheses to output'
)
group
.
add_argument
(
'--max-len-a'
,
default
=
0
,
type
=
in
t
,
metavar
=
'N'
,
help
=
(
'generate sequence of maximum length ax + b, '
group
.
add_argument
(
'--max-len-a'
,
default
=
0
,
type
=
floa
t
,
metavar
=
'N'
,
help
=
(
'generate sequence
s
of maximum length ax + b, '
'where x is the source length'
))
group
.
add_argument
(
'--max-len-b'
,
default
=
200
,
type
=
int
,
metavar
=
'N'
,
help
=
(
'generate sequence of maximum length ax + b, '
help
=
(
'generate sequence
s
of maximum length ax + b, '
'where x is the source length'
))
group
.
add_argument
(
'--remove-bpe'
,
nargs
=
'?'
,
const
=
'@@ '
,
default
=
None
,
help
=
'remove BPE tokens before scoring'
)
...
...
fairseq/sequence_generator.py
View file @
48631f7a
...
...
@@ -48,7 +48,7 @@ class SequenceGenerator(object):
self
.
positions
=
self
.
positions
.
cuda
()
return
self
def
generate_batched_itr
(
self
,
data_itr
,
maxlen_a
=
0
,
maxlen_b
=
200
,
def
generate_batched_itr
(
self
,
data_itr
,
maxlen_a
=
0
.0
,
maxlen_b
=
200
,
cuda_device
=
None
,
timer
=
None
):
"""Iterate over a batched dataset and yield individual translations.
...
...
@@ -69,7 +69,7 @@ class SequenceGenerator(object):
if
timer
is
not
None
:
timer
.
start
()
hypos
=
self
.
generate
(
input
[
'src_tokens'
],
input
[
'src_positions'
],
maxlen
=
(
maxlen_a
*
srclen
+
maxlen_b
))
maxlen
=
int
(
maxlen_a
*
srclen
+
maxlen_b
))
if
timer
is
not
None
:
timer
.
stop
(
s
[
'ntokens'
])
for
i
,
id
in
enumerate
(
s
[
'id'
]):
...
...
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