Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
87d60b6e
Commit
87d60b6e
authored
Oct 17, 2019
by
Rémi Louf
Browse files
reword explanation of encoder_attention_mask
parent
638fe7f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
transformers/modeling_bert.py
transformers/modeling_bert.py
+3
-3
No files found.
transformers/modeling_bert.py
View file @
87d60b6e
...
...
@@ -201,9 +201,9 @@ class BertSelfAttention(nn.Module):
def
forward
(
self
,
hidden_states
,
attention_mask
=
None
,
head_mask
=
None
,
encoder_hidden_states
=
None
,
encoder_attention_mask
=
None
):
mixed_query_layer
=
self
.
query
(
hidden_states
)
#
i
f th
e attention Module is a encoder-decoder self
attention module
#
they keys & values are given by the
encoder; the attention mask
#
needs to be such that there is no atention on
the encoder's padding tokens.
#
I
f th
is is instantiated as a cross-
attention module
, the keys
#
and values come from an
encoder; the attention mask
needs to be
#
such that
the encoder's padding tokens
are not attended to
.
if
encoder_hidden_states
is
not
None
:
mixed_key_layer
=
self
.
key
(
encoder_hidden_states
)
mixed_value_layer
=
self
.
value
(
encoder_hidden_states
)
...
...
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