title: Why 'image_dataset_from directory' (keras, tensorflow) is returning an object of BatchDataset = None?
body: <p>I am trying to create a <strong>LeNet5</strong> for the images supplied in <a href="http://chaladze.com/l5/" rel="nofollow noreferrer">this link</a>.</p>
  <p>In order to upload the training and test sets, I use</p>
  <pre><code>tf.keras.preprocessing.image_dataset_from_directory:
      train_set = image_dataset_from_directory('Linnaeus_5_32X32/train',
                                          labels='inferred',
                                          label_mode = 'categorical',
                                          color_mode = 'grayscale',
                                          batch_size=batch_size,
                                          image_size = (image_rows,image_cols),
                                          shuffle=True,
                                          seed=1997)
  
      test_set = image_dataset_from_directory('Linnaeus_5_32X32/test',
                                              labels='inferred',
                                              label_mode = 'categorical',
                                              color_mode = 'grayscale',
                                              batch_size = batch_size,
                                              image_size = (image_rows,image_cols),
                                              shuffle=True,
                                              seed=1997)
  </code></pre>
  <p>This should returns a <code>tf.data.Dataset</code> object that is a tuple (images, labels), where images has shape (<code>batch_size, image_size[0], image_size[1], num_channels</code>), and labels follows the format (batch_size, num_classes).</p>
  <p>However, this is what I get, printed on the screen:</p>
  <pre><code>  Found 6000 files belonging to 5 classes.
    Found 2000 files belonging to 5 classes.
  </code></pre>
  <p>This is correct because I have 6000 train images and 2000 test images. But when I inspect, for example, the training_set I get:</p>
  <pre><code>&lt;BatchDataset shapes: ((None, 32, 32, 1), (None, 5)), types: (tf.float32, tf.float32)&gt;
  </code></pre>
  <p>That is, batch_size = None when it should be 6000.</p>
  <p>What does this mean? How can I fix it?</p>