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
7b086021
"server/text_generation_server/models/idefics.py" did not exist on "32a253063dae768e71a0b0aa099cfbbe962032d1"
Commit
7b086021
authored
Nov 12, 2017
by
Myle Ott
Browse files
Make LSTM backwards compatible and fix incremental generation
parent
63dc27e8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
fairseq/models/lstm.py
fairseq/models/lstm.py
+6
-1
No files found.
fairseq/models/lstm.py
View file @
7b086021
...
...
@@ -94,7 +94,7 @@ class AttentionLayer(nn.Module):
# compute attention
attn_scores
=
(
source_hids
*
x
.
unsqueeze
(
0
)).
sum
(
dim
=
2
)
attn_scores
=
F
.
softmax
(
attn_scores
.
t
()
,
dim
=
1
).
t
()
# srclen x bsz
attn_scores
=
F
.
softmax
(
attn_scores
.
t
()).
t
()
# srclen x bsz
# sum weighted sources
x
=
(
attn_scores
.
unsqueeze
(
2
)
*
source_hids
).
sum
(
dim
=
0
)
...
...
@@ -125,6 +125,11 @@ class LSTMDecoder(FairseqIncrementalDecoder):
self
.
fc_out
=
Linear
(
out_embed_dim
,
num_embeddings
,
dropout
=
dropout_out
)
def
forward
(
self
,
input_tokens
,
encoder_out
):
if
self
.
_is_incremental_eval
:
input_tokens
=
input_tokens
[:,
-
1
:]
return
self
.
_forward
(
input_tokens
,
encoder_out
)
def
_forward
(
self
,
input_tokens
,
encoder_out
):
bsz
,
seqlen
=
input_tokens
.
size
()
# get outputs from encoder
...
...
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