title: Tensorflow cannot get `image.shape` from method in `dataset.map( mapFn )`
body: <p>I'm trying to do the <code>tensorflow</code> equivalent of <code>torch.transforms.Resize(TRAIN_IMAGE_SIZE)</code>, which resizes the <strong>smallest</strong> image dimension to <code>TRAIN_IMAGE_SIZE</code>. Something like this</p>
  
  <pre><code>def transforms(filename):
    parts = tf.strings.split(filename, '/')
    label = parts[-2]
  
    image = tf.io.read_file(filename)
    image = tf.image.decode_jpeg(image)
    image = tf.image.convert_image_dtype(image, tf.float32)
  
    # this doesn't work with Dataset.map() because image.shape=(None,None,3) from Dataset.map()
    image = largest_sq_crop(image) 
  
    image = tf.image.resize(image, (256,256))
    return image, label
  
  list_ds = tf.data.Dataset.list_files('{}/*/*'.format(DATASET_PATH))
  images_ds = list_ds.map(transforms).batch(4)
  </code></pre>
  
  <p>The simple answer is here: <a href="https://stackoverflow.com/questions/54865717/tensorflow-crop-largest-central-square-region-of-image">Tensorflow: Crop largest central square region of image</a></p>
  
  <p>But when I use the method with <code>tf.data.Dataset.map(transforms)</code>, I get <code>shape=(None,None,3)</code> from inside <code>largest_sq_crop(image)</code>. The method works fine when I call it normally.</p>