title: keras mask not propagated
body: <p>Keras (tensorflow 2.6 backend) masks supposed to propagate through the network, <a href="https://www.tensorflow.org/guide/keras/masking_and_padding#mask_propagation_in_the_functional_api_and_sequential_api" rel="nofollow noreferrer">as mentioned in the docs</a>:</p>
  <blockquote>
  <p>When using the Functional API or the Sequential API, a mask generated by an Embedding or Masking layer will be propagated through the network for any layer that is capable of using them.</p>
  </blockquote>
  <p>Both <code>Conv1D</code> and <code>GlobalMaxPool1D</code> support masks but mask is not propagated, as demonstrated by the following example,</p>
  <ol>
  <li><code>model1</code> applies mask and <code>GlobalMaxPool1D</code></li>
  <li><code>model2</code> applies mask and <code>Conv1D</code></li>
  <li><code>model3</code> applies mask and <code>Conv1D</code> followed by <code>GlobalMaxPool1D</code></li>
  </ol>
  <pre><code>from tensorflow.keras import layers
  from tensorflow.keras import models
  from tensorflow.keras import initializers
  import numpy as np
  
  mask_val = 10.
  inp = layers.Input(shape = (4,3))
  masked = layers.Masking(mask_value = mask_val)(inp)
  max_pool = layers.GlobalMaxPool1D()(masked)
  model1 = keras.models.Model(inputs = inp, outputs = max_pool)
  #--- initialize the conv kernel to -1. so it's easy to interpret output
  conv = layers.Conv1D(1, 2, padding = 'valid', kernel_initializer = initializers.Constant(-1.))(masked)
  model2 = keras.models.Model(inputs = inp, outputs = conv)
  out = layers.GlobalMaxPool1D()(conv)
  model3 = models.Model(inputs = inp, outputs = out)
  </code></pre>
  <p>Now test these 3 models on a simple input, 2 samples of dimension 3, followed by 2 masked samples:</p>
  <pre><code>x0 = np.concatenate((np.ones((1,2,3)), mask_val * np.ones((1,2,3))), axis = 1)
  model1(x0) # outputs [1,1,1], as expected
  model2(x0) # outputs [-6, -3, 0] as expected
  model3(x0) # outputs [0], but should output [-3] as the 0 value should be masked
  </code></pre>
  <p>Am I missing something?</p>