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
af38ed48
Unverified
Commit
af38ed48
authored
Aug 16, 2018
by
Myle Ott
Committed by
GitHub
Aug 16, 2018
Browse files
Fix bidirectional LSTM concatenation (#249)
parent
53c7d271
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
4 deletions
+1
-4
fairseq/models/lstm.py
fairseq/models/lstm.py
+1
-4
No files found.
fairseq/models/lstm.py
View file @
af38ed48
...
@@ -222,10 +222,7 @@ class LSTMEncoder(FairseqEncoder):
...
@@ -222,10 +222,7 @@ class LSTMEncoder(FairseqEncoder):
if
self
.
bidirectional
:
if
self
.
bidirectional
:
def
combine_bidir
(
outs
):
def
combine_bidir
(
outs
):
return
torch
.
cat
([
return
outs
.
view
(
self
.
num_layers
,
2
,
bsz
,
-
1
).
transpose
(
1
,
2
).
contiguous
().
view
(
self
.
num_layers
,
bsz
,
-
1
)
torch
.
cat
([
outs
[
2
*
i
],
outs
[
2
*
i
+
1
]],
dim
=
0
).
view
(
1
,
bsz
,
self
.
output_units
)
for
i
in
range
(
self
.
num_layers
)
],
dim
=
0
)
final_hiddens
=
combine_bidir
(
final_hiddens
)
final_hiddens
=
combine_bidir
(
final_hiddens
)
final_cells
=
combine_bidir
(
final_cells
)
final_cells
=
combine_bidir
(
final_cells
)
...
...
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