title: How to convert numpy based function for TensorFlow tensor?
body: <p>I'm trying to implement this below function with <code>tf.xyz</code> modules available in TensorFlow <a href="https://www.tensorflow.org/api_guides/python/array_ops" rel="nofollow noreferrer">here</a>. This below NumPy based function takes the 3D matrix as input, checks the condition with the values of last column and returns the values from first two columns which satisfy the condition. </p>
  
  <p>I'm having hard time converting this NumPy based modules for TensorFlow tensors which I want to add in as lambda layer to my model. Any suggestion? </p>
  
  <p>I'm trying with <code>tf.greater()</code> and <code>tf.slice()</code> but not getting the same output as NumPy version of the function.</p>
  
  <pre><code># NumPy based function on 3D matrix:
  def fun1(arr):
     return arr[arr[:,2] &gt; 0.95][:,:2]  
  
  input_matrix = np.array([[[1, 2, 0.99], [11, 22, 0.80], [111, 222, 0.96]]])
  
  &gt;&gt; input_matrix
  [[[  1.     2.     0.99]
  [ 11.    22.     0.8 ]
  [111.   222.     0.96]]]
  
  &gt;&gt; np.array([fun1(i) for i in input_matrix])
  array([[[  1.,   2.],
          [111., 222.]]])
  </code></pre>