title: How does mask_zero in Keras Embedding layer work?
body: <p>I thought <code>mask_zero=True</code> will output 0's when the input value is 0, so the following layers could skip computation or something.</p>
  
  <p>How does <code>mask_zero</code> works? </p>
  
  <p>Example: </p>
  
  <pre><code>data_in = np.array([
    [1, 2, 0, 0]
  ])
  data_in.shape
  &gt;&gt;&gt; (1, 4)
  
  # model
  x = Input(shape=(4,))
  e = Embedding(5, 5, mask_zero=True)(x)
  
  m = Model(inputs=x, outputs=e)
  p = m.predict(data_in)
  print(p.shape)
  print(p)
  </code></pre>
  
  <p>The actual output is: (the numbers are random)</p>
  
  <pre><code>(1, 4, 5)
  [[[ 0.02499047  0.04617121  0.01586803  0.0338897   0.009652  ]
    [ 0.04782704 -0.04035913 -0.0341589   0.03020919 -0.01157228]
    [ 0.00451764 -0.01433611  0.02606953  0.00328832  0.02650392]
    [ 0.00451764 -0.01433611  0.02606953  0.00328832  0.02650392]]]
  </code></pre>
  
  <p>However, I thought the output will be:</p>
  
  <pre><code>[[[ 0.02499047  0.04617121  0.01586803  0.0338897   0.009652  ]
    [ 0.04782704 -0.04035913 -0.0341589   0.03020919 -0.01157228]
    [ 0 0 0 0 0]
    [ 0 0 0 0 0]]]
  </code></pre>