title: Removing or masking the I'th sub-element of a tilted tensor?
body: <p>I am searching for a way using Tensorflow to extract all of the sub-elements except for the one corresponding to the tensor's index.</p>
  
  <p>(eg. if looking at index 1 then only sub-elements 0 and 2 are present)</p>
  
  <p>Very similar to <a href="https://stackoverflow.com/a/41780121/3961748">this approach</a> using Numpy.</p>
  
  <p>Here's some example code to create a tiled tensor and a boolean mask: </p>
  
  <pre><code>import tensorflow as tf
  import numpy as np
  
  _coordinates = np.array([
      [1.0, 7.0, 0.0],
      [2.0, 7.0, 0.0],
      [3.0, 7.0, 0.0],
  ])
  
  verts_coord = _coordinates
  n = verts_coord.shape[0]
  
  mat_loc = tf.Variable(verts_coord)
  
  tile = tf.tile(mat_loc, [n, 1])
  tile = tf.reshape(tile, [n, n, n])
  
  mask = tf.constant(~np.eye(n, dtype=bool))
  
  result = tf.somefunc(tile, mask) #somehow extract only the elements where mask == true
  
  with tf.Session() as sess:
      sess.run(tf.initialize_all_variables())
      print(sess.run(tile))
      print(sess.run(mask))
  </code></pre>
  
  <p>Example output tensors: </p>
  
  <pre><code>&gt;&gt;&gt; print(tile)
  [[[ 1.  7.  0.]
    [ 2.  7.  0.]
    [ 3.  7.  0.]]
  
   [[ 1.  7.  0.]
    [ 2.  7.  0.]
    [ 3.  7.  0.]]
  
   [[ 1.  7.  0.]
    [ 2.  7.  0.]
    [ 3.  7.  0.]]]
  
  &gt;&gt;&gt; print(mask)
  [[False  True  True]
   [ True False  True]
   [ True  True False]]
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>&gt;&gt;&gt; print(result)
  [[[ 2.  7.  0.]
    [ 3.  7.  0.]]
  
   [[ 1.  7.  0.]
    [ 3.  7.  0.]]
  
   [[ 1.  7.  0.]
    [ 2.  7.  0.]]]
  </code></pre>
  
  <p>I am also curious if there are more efficient methods for doing this as opposed to creating a large tensor and then masking it?</p>
  
  <p>Thanks! </p>