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
6e4d370a
Unverified
Commit
6e4d370a
authored
Mar 01, 2018
by
Myle Ott
Committed by
GitHub
Mar 01, 2018
Browse files
More updates for PyTorch (#114)
parent
3bde773d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
7 deletions
+5
-7
fairseq/models/lstm.py
fairseq/models/lstm.py
+3
-3
fairseq/utils.py
fairseq/utils.py
+0
-2
requirements.txt
requirements.txt
+1
-1
tests/test_utils.py
tests/test_utils.py
+1
-1
No files found.
fairseq/models/lstm.py
View file @
6e4d370a
...
...
@@ -96,9 +96,9 @@ class LSTMEncoder(FairseqEncoder):
def
forward
(
self
,
src_tokens
,
src_lengths
):
if
LanguagePairDataset
.
LEFT_PAD_SOURCE
:
# convert left-padding to right-padding
src_tokens
.
data
=
utils
.
convert_padding_direction
(
src_tokens
.
data
,
src_lengths
.
data
,
src_tokens
=
utils
.
convert_padding_direction
(
src_tokens
,
src_lengths
,
self
.
padding_idx
,
left_to_right
=
True
,
)
...
...
fairseq/utils.py
View file @
6e4d370a
...
...
@@ -289,8 +289,6 @@ def convert_padding_direction(
right_to_left
=
False
,
left_to_right
=
False
,
):
assert
not
isinstance
(
src_tokens
,
Variable
)
assert
not
isinstance
(
src_lengths
,
Variable
)
assert
right_to_left
^
left_to_right
pad_mask
=
src_tokens
.
eq
(
padding_idx
)
if
pad_mask
.
max
()
==
0
:
...
...
requirements.txt
View file @
6e4d370a
cffi
numpy
torch
>=0.4.0
torch
tqdm
tests/test_utils.py
View file @
6e4d370a
...
...
@@ -61,7 +61,7 @@ class TestUtils(unittest.TestCase):
def
assertAlmostEqual
(
self
,
t1
,
t2
):
self
.
assertEqual
(
t1
.
size
(),
t2
.
size
(),
"size mismatch"
)
self
.
assertLess
((
t1
-
t2
).
abs
().
max
(),
1e-4
)
self
.
assertLess
(
utils
.
item
(
(
t1
-
t2
).
abs
().
max
()
)
,
1e-4
)
if
__name__
==
'__main__'
:
...
...
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