title: AttributeError: 'DirectoryIterator' object has no attribute 'shape' Tensorflow CNN
body: <p>I am trying to use the <code>fit_generator</code> to fit a model.  Everything works up to the fit, but it is throwing the error above.  I am using Keras 2.2.4, and TF 2.0.0.  All other previous CNNs have worked, but it does not like the image generator.</p>
  <pre><code># import relevant functions
  from tensorflow.keras.preprocessing.image import ImageDataGenerator
  from tensorflow.keras import Sequential
  from tensorflow.keras.layers import Conv2D
  
  # rotate, and shift data
  image_gen = ImageDataGenerator(rotation_range=20,
                                width_shift_range=0.1,
                                height_shift_range=0.1,
                                shear_range=0.1,
                                zoom_range=0.1,
                                horizontal_flip=True,
                                fill_mode='nearest')
  # build the model
  model = Sequential()
  
  model.add(Conv2D(filters=32, kernel_size=(3,3),input_shape=image_shape, activation='relu',))
  model.add(MaxPool2D(pool_size=(2, 2)))
  
  model.add(Conv2D(filters=64, kernel_size=(3,3),input_shape=image_shape, activation='relu',))
  model.add(MaxPool2D(pool_size=(2, 2)))
  
  model.add(Conv2D(filters=64, kernel_size=(3,3),input_shape=image_shape, activation='relu',))
  model.add(MaxPool2D(pool_size=(2, 2)))
  
  model.add(Flatten())
  
  model.add(Dense(128, activation='relu'))
  model.add(Dropout(0.5))
  
  model.add(Dense(1, activation='sigmoid'))
  
  model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  
  # set up early stopping
  early_stopping = EarlyStopping(monitor='val_loss', patience=2)
  
  batch_size=16
  
  # build train and test generators
  train_image_gen = image_gen.flow_from_directory(train_path,
                                                 target_size = image_shape[:2],
                                                 color_mode='rgb',
                                                 batch_size=batch_size,
                                                 class_mode='binary')
  
  # don't shuffle test data
  
  test_image_gen = image_gen.flow_from_directory(test_path,
                                                 target_size = image_shape[:2],
                                                 color_mode='rgb',
                                                 batch_size=batch_size,
                                                 class_mode='binary',
                                                 shuffle=False)
  
  # fit on the generators
  results = model.fit_generator(train_image_gen, epochs=20,
                               validation_data=test_image_gen,
                               callbacks=[early_stopping])
  </code></pre>
  <p>From the snapshots of my notebook, everything works except for the `model.fit_generator' step.</p>
  <p><a href="https://i.stack.imgur.com/2PAQj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2PAQj.png" alt="enter image description here" /></a></p>
  <p>When I run the last step, I get the error.</p>
  <p><a href="https://i.stack.imgur.com/E9wsQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E9wsQ.png" alt="enter image description here" /></a></p>
  <p>The <code>train_image_gen</code> and <code>test_image_gen</code> object appear to be correct with proper references to the directories for a binary image classification problem.</p>
  <p>The directories are set up properly too:</p>
  <p><a href="https://i.stack.imgur.com/0acZG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0acZG.png" alt="enter image description here" /></a></p>