title: Is there a way to efficiently vectorize Tensorflow ops on images?
body: <p>Tensorflow has a great deal of transformations that can be applied to 3D-tensors representing images ([height, width, depth]) like <code>tf.image.rot90()</code> or <code>tf.image.random_flip_left_right()</code> for example.  </p>
  
  <p>I know that they are meant to be used with queues hence the fact that they operate on only one image.  </p>
  
  <p>But would there be a way to vectorize the ops to transform 4D-tensor ([batch_size,height,width,depth]) to same size tensor with op applied image-wise along the first dimension without explicitely looping through them with <code>tf.while_loop()</code>?</p>
  
  <p>(<strong>EDIT :</strong> Regarding <code>rot90()</code> a clever hack taken from numpy rot90 would be to do:</p>
  
  <pre><code>rot90=tf.reverse(x,tf.convert_to_tensor((False,False,True,False)))
  rot90=tf.transpose(rot90,([0,2,1,3])
  </code></pre>
  
  <p><strong>EDIT 2:</strong> It turns out this question has already been answered quite a few times (<a href="https://stackoverflow.com/questions/38920240/tensorflow-image-operations-for-batches/38922192#38922192">one example</a>) it seems <code>map_fn</code> is the way to go if you want an optimized version. I had already seen it but I had forgotten. I guess this makes this question a duplicate...</p>
  
  <p>However for random op or more complex op it would be nice to have a generic method to vectorize existing functions...)</p>