title: how does tensorflow indexing work
body: <p>I'm having trouble understanding a basic concept with tensorflow. How does indexing work for tensor read/write operations? In order to make this specific, how can the following numpy examples be translated to tensorflow (using tensors for the arrays, indices and values being assigned):</p>
  
  <pre><code>x = np.zeros((3, 4))
  row_indices = np.array([1, 1, 2])
  col_indices = np.array([0, 2, 3])
  x[row_indices, col_indices] = 2
  x
  </code></pre>
  
  <p>with output:</p>
  
  <pre><code>array([[ 0.,  0.,  0.,  0.],
         [ 2.,  0.,  2.,  0.],
         [ 0.,  0.,  0.,  2.]])
  </code></pre>
  
  <p>... and ...</p>
  
  <pre><code>x[row_indices, col_indices] = np.array([5, 4, 3])
  x
  </code></pre>
  
  <p>with output:</p>
  
  <pre><code>array([[ 0.,  0.,  0.,  0.],
         [ 5.,  0.,  4.,  0.],
         [ 0.,  0.,  0.,  3.]])
  </code></pre>
  
  <p>... and finally ...</p>
  
  <pre><code>y = x[row_indices, col_indices]
  y
  </code></pre>
  
  <p>with output:</p>
  
  <pre><code>array([ 5.,  4.,  3.])
  </code></pre>