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
d473620e
Commit
d473620e
authored
Sep 02, 2018
by
Myle Ott
Browse files
Test max_positions
parent
dfd77717
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
tests/test_binaries.py
tests/test_binaries.py
+21
-0
No files found.
tests/test_binaries.py
View file @
d473620e
...
@@ -58,6 +58,27 @@ class TestTranslation(unittest.TestCase):
...
@@ -58,6 +58,27 @@ class TestTranslation(unittest.TestCase):
train_translation_model
(
data_dir
,
'fconv_iwslt_de_en'
,
[
'--update-freq'
,
'3'
])
train_translation_model
(
data_dir
,
'fconv_iwslt_de_en'
,
[
'--update-freq'
,
'3'
])
generate_main
(
data_dir
)
generate_main
(
data_dir
)
def
test_max_positions
(
self
):
with
contextlib
.
redirect_stdout
(
StringIO
()):
with
tempfile
.
TemporaryDirectory
(
'test_max_positions'
)
as
data_dir
:
create_dummy_data
(
data_dir
)
preprocess_translation_data
(
data_dir
)
with
self
.
assertRaises
(
Exception
)
as
context
:
train_translation_model
(
data_dir
,
'fconv_iwslt_de_en'
,
[
'--max-target-positions'
,
'5'
],
)
self
.
assertTrue
(
'skip this example with --skip-invalid-size-inputs-valid-test'
\
in
str
(
context
.
exception
)
)
train_translation_model
(
data_dir
,
'fconv_iwslt_de_en'
,
[
'--max-target-positions'
,
'5'
,
'--skip-invalid-size-inputs-valid-test'
],
)
with
self
.
assertRaises
(
Exception
)
as
context
:
generate_main
(
data_dir
)
generate_main
(
data_dir
,
[
'--skip-invalid-size-inputs-valid-test'
])
def
test_generation
(
self
):
def
test_generation
(
self
):
with
contextlib
.
redirect_stdout
(
StringIO
()):
with
contextlib
.
redirect_stdout
(
StringIO
()):
with
tempfile
.
TemporaryDirectory
(
'test_sampling'
)
as
data_dir
:
with
tempfile
.
TemporaryDirectory
(
'test_sampling'
)
as
data_dir
:
...
...
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