title: Tensorflow Datasets: Make batches with different shaped data
body: <pre class="lang-py prettyprint-override"><code>import tensorflow_datasets as tfds
  import tensorflow as tf
  
  def input_fn():
  
      dataset_builder = tfds.builder("oxford_flowers102")
      dataset_builder.download_and_prepare()
  
      ds = dataset_builder.as_dataset(split=tfds.Split.TRAIN)
      ds = ds.repeat()
      ds = ds.batch(32)
      return ds
  
  </code></pre>
  
  <p>will result in </p>
  
  <pre><code>InvalidArgumentError: Cannot batch tensors with different shapes in component 1. 
  First element had shape [500,666,3] and element 1 had shape [752,500,3]. 
  [Op:IteratorGetNextSync]
  </code></pre>
  
  <p>This can be solved by using a resize/pad function that returns images of same shape as shown <a href="https://stackoverflow.com/a/57657510/3125070">here</a> and <a href="https://stackoverflow.com/a/47142989/3125070">here</a></p>
  
  <pre><code>ds = ds.map(resize_or_pad_function)
  ds = ds.batch(...)
  </code></pre>
  
  <p>However, I do not want to resize or pad my images, as I want to retain the original size and aspect of images. It is for training a convolutional neural network that can accept varied images sizes.</p>
  
  <p>What do I do if I need batches of tensors with shape <code>(32, None, None, 3)</code> where each image has a different height and width?</p>