'Will a Tensorflow/Keras mask still flow to subsequent layers if I manually manipulate a tensor between layers?

Say these are the layers of my model:

  1. Embedding with mask_zero=True
  2. LSTM
  3. Dense

According to the official guide: https://www.tensorflow.org/guide/keras/masking_and_padding

And this SO answer: How does mask_zero in Keras Embedding layer work?

The mask should propagate through the subsequent layers as long as they support masking (Which LSTM and Dense do).

But let's say I take the LSTM output from step 2, and do some matrix operations on it before passing it to step 3. Will the Dense layer in step 3 still receive the mask?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source