title: Load data on demand using flow_from_directory for AutoEncoder
body: <p>I am trying to train an AutoEncoder on some image data. The dataset is so huge so that it won't fit in memory. So obviously I want to load the data from the directory on demand with the help of <code>flow_from_directory</code> in Keras.</p>
  
  
  
  <p>My dataset is in the following structure</p>
  
  <pre class="lang-python prettyprint-override"><code>./Dataset/
      ./Train/
          ../1.jpg
          ../2.jpg
  </code></pre>
  
  <p>and so on.</p>
  
  <p>I tried to use <code>flow_from_directory</code> like this</p>
  
  <pre class="lang-python prettyprint-override"><code>train_generator = datagen.flow_from_directory(
      TRAIN_FOLDER,
      target_size = (256, 256),
      color_mode = 'rgb',
      batch_size = batch_size,
      class_mode = 'input')
  </code></pre>
  
  <p>This gives me an output <code>Found 0 images belonging to 0 classes.</code> I will get a <code>ZeroDivisionError</code> if I try to fit the model with this generator.</p>
  
  <p>I have used the <code>flow_from_directory</code>, <code>flow</code> and <code>flow_from_dataframe</code> in various occasions but in those cases, I was going for a classification problem and had n folders in the directory for n classes. </p>
  
  <p>How can I load images from the directory on demand for training auto encoder.? From the Keras docs over <a href="https://keras.io/preprocessing/image/#flow_from_directory" rel="nofollow noreferrer">here</a> I saw </p>
  
  <p><code>class_mode : "input" will be images identical to input images (mainly used to work with autoencoders)</code> </p>
  
  <p>But this is not fixing the problem either.</p>
  
  <p>One workaround I found was making another folder inside the train and moving all the files into that. Is there any direct method other than this.?</p>