Skip to content

Modify TransformerEncoder masking documentation #2297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions keras_hub/src/layers/modeling/transformer_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ class TransformerEncoder(keras.layers.Layer):
paper [Attention is All You Need](https://arxiv.org/abs/1706.03762). Users
can instantiate multiple instances of this class to stack up an encoder.

This layer will correctly compute an attention mask from an implicit
Keras padding mask (for example, by passing `mask_zero=True` to a
`keras.layers.Embedding` layer). See the Masking and Padding
This layer will compute an attention mask, prioritizing explicitly provided
masks(a `padding_mask` or a custom `attention_mask`) over an implicit Keras
padding mask (for example, by passing `mask_zero=True` to a
`keras.layers.Embedding` layer). If both a `padding_mask` and a
`attention_mask` are provided, they will be combined to determine the final
mask. See the Masking and Padding
[guide](https://keras.io/guides/understanding_masking_and_padding/)
for more details.

Expand Down
Loading