Answers.Body: <p>Masks in Recurrent Neural Networks are used to transform variable-length inputs to one general length. <a href="https://www.tensorflow.org/guide/keras/masking_and_padding" rel="nofollow noreferrer">Therefore we use padding and masking together</a>.</p>
  <p>Padding: Usually we create a vector for every sentence in the dataset initialized with 0s and the length of the longest sentence in the dataset. Then we fill the mask with 1s for every position the sentence has words in.</p>
  <p>Masking: Now we need to inform the network that some values in the vector are actually padding and should not be used since they have no information.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-31T13:00:58.523Z
Answers.LastActivityDate: 2022-01-02T23:45:33.723Z
Answers.LastEditDate: 2022-01-02T23:45:33.723Z
Answers.UserDisplayName: technik
Body: <p>While reading source code related to RNN encoders, I've come across the term <strong>mask</strong> as input to the encoder. What exactly is it?</p>
  
Tags: <deep-learning><terminology><recurrent-neural-networks><encoder-decoder>
Title: What is a "mask" in the context o RNN-based encoders?
UserDisplayName: hanugm
ThreadText: # What is a "mask" in the context o RNN-based encoders?
  
  (Asked by: username_0 on 2021-12-11)
  
  While reading source code related to RNN encoders, I've come across the term **mask** as input to the encoder. What exactly is it?
  
  **Tags:** deep-learning, terminology, recurrent-neural-networks, encoder-decoder
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-31. Score: 1 | Accepted answer
  
  Masks in Recurrent Neural Networks are used to transform variable-length inputs to one general length. [Therefore we use padding and masking together](https://www.tensorflow.org/guide/keras/masking_and_padding).
  
  Padding: Usually we create a vector for every sentence in the dataset initialized with 0s and the length of the longest sentence in the dataset. Then we fill the mask with 1s for every position the sentence has words in.
  
  Masking: Now we need to inform the network that some values in the vector are actually padding and should not be used since they have no information.
  
  
  ---
  
  