A mask marks padded or irrelevant sequence positions so later layers ignore them. In a padded review sequence, masking prevents repeated [PAD] tokens from replacing the meaningful final representation, such as “awful.” section 14.5.3
Use masking in two practical ways:
- Enable implicit masking with mask_zero=True in a Keras Embedding layer when token ID zero represents [PAD]. section 14.5.3
- Pass an explicit mask to an LSTM when masking rules are custom or cannot rely on zero-valued token IDs. section 14.5.3






