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
90b2d8de
Commit
90b2d8de
authored
Nov 24, 2017
by
Zrachel
Committed by
Myle Ott
Nov 24, 2017
Browse files
fix bug in lstm model (#68)
parent
884e3046
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
fairseq/models/lstm.py
fairseq/models/lstm.py
+5
-0
No files found.
fairseq/models/lstm.py
View file @
90b2d8de
...
@@ -122,6 +122,8 @@ class LSTMDecoder(FairseqIncrementalDecoder):
...
@@ -122,6 +122,8 @@ class LSTMDecoder(FairseqIncrementalDecoder):
for
layer
in
range
(
num_layers
)
for
layer
in
range
(
num_layers
)
])
])
self
.
attention
=
AttentionLayer
(
encoder_embed_dim
,
embed_dim
)
self
.
attention
=
AttentionLayer
(
encoder_embed_dim
,
embed_dim
)
if
embed_dim
!=
out_embed_dim
:
self
.
additional_fc
=
Linear
(
embed_dim
,
out_embed_dim
)
self
.
fc_out
=
Linear
(
out_embed_dim
,
num_embeddings
,
dropout
=
dropout_out
)
self
.
fc_out
=
Linear
(
out_embed_dim
,
num_embeddings
,
dropout
=
dropout_out
)
def
forward
(
self
,
input_tokens
,
encoder_out
):
def
forward
(
self
,
input_tokens
,
encoder_out
):
...
@@ -197,6 +199,9 @@ class LSTMDecoder(FairseqIncrementalDecoder):
...
@@ -197,6 +199,9 @@ class LSTMDecoder(FairseqIncrementalDecoder):
attn_scores
=
attn_scores
.
transpose
(
0
,
2
)
attn_scores
=
attn_scores
.
transpose
(
0
,
2
)
# project back to size of vocabulary
# project back to size of vocabulary
if
hasattr
(
self
,
'additional_fc'
):
x
=
self
.
additional_fc
(
x
)
x
=
F
.
dropout
(
x
,
p
=
self
.
dropout_out
,
training
=
self
.
training
)
x
=
self
.
fc_out
(
x
)
x
=
self
.
fc_out
(
x
)
return
x
,
attn_scores
return
x
,
attn_scores
...
...
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