title: Mask and reshape a matrix using Tensorflow
body: <p>I would like to use a <code>mask</code> to select vectors in <code>mat</code> variable. Below is the resultant matrix that I expcxt to get:</p>
  <pre><code>[[0, 0, 2, 2],
   [4, 4, 5, 5],
   [8, 8, 9, 9]]
  </code></pre>
  <p>Below is the code that I use:</p>
  <pre><code>mat = tf.constant([[[0, 0], [1, 1], [2, 2]], 
                     [[4, 4], [5, 5], [6, 6]], 
                     [[7, 7], [8, 8], [9, 9]]])
  mask = tf.constant([[True, False, True], 
                      [True, True, False], 
                      [False, True, True]])
  masked = tf.boolean_mask(mat, mask)
  res = tf.keras.layers.Reshape([4])(masked)
  
  with tf.Session() as sess:
      print(res.eval())
  </code></pre>
  <p>However, I get an error:</p>
  <pre><code>tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 12 values, but the requested shape has 24
       [[{{node reshape/Reshape}}]]
  </code></pre>
  <p>How should I handle this issue?</p>