title: How to random_crop an unlabeled tensorflow Dataset? ValueError: Dimensions must be equal, but are 4 and 3
body: <p>I am trying to augment (random crop) images while loading them using a tensorflow Dataset.
  I am getting this error when I call the method <strong>tf.image.random_crop</strong> in the mapped function:</p>
  <pre><code>    ValueError: Dimensions must be equal, but are 4 and 3 for '{{node random_crop/GreaterEqual}} = GreaterEqual[T=DT_INT32](random_crop/Shape, random_crop/size)' with input shapes: [4], [3].
  </code></pre>
  <p>In order to reproduce the error, just place some png images in the directory:</p>
  <pre><code>./img/class0/
  </code></pre>
  <p>Then run this code:</p>
  <pre><code>import os
  import tensorflow as tf
  
  train_set_raw = tf.keras.preprocessing.image_dataset_from_directory('./img',label_mode=None,validation_split=None,batch_size=32)
  
  def augment(tensor):
      tensor = tf.cast(x=tensor, dtype=tf.float32)
      tensor = tf.divide(x=tensor, y=tf.constant(255.))
      tensor = tf.image.random_crop(value=tensor, size=(256, 256, 3))
      return tensor
  
  train_set_raw = train_set_raw.map(augment).batch(32)
  </code></pre>
  <p>If I specify the batch size explicitly,</p>
  <pre><code>tensor = tf.image.random_crop(value=tensor, size=(32,256, 256, 3))
  </code></pre>
  <p>the error can be sorted. However, if you try to fit a model with a dataset created with a fixed batch size, you will get an error:</p>
  <pre><code>tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [Need value.shape &gt;= size, got ] [1 256 256 3] [32 256 256 3]
   [[{{node random_crop/Assert/Assert}}]]
  </code></pre>