title: Not able to use the model.fit() in Keras
body: <p>Please help me run the code. This doesn't work. I have been trying hard to solve this for days. The model_final.fit() also doesn't work. Why is this showing the same error for the method. This is almost the entire code.</p>
  <p>EDIT: The train_generator and validation_generator added.</p>
  <pre><code>img_width, img_height = 400, 400
  train_data_dir = &quot;data/train&quot;
  validation_data_dir = &quot;data/validation&quot;
  nb_train_samples = 4125
  nb_validation_samples = 466
  batch_size = 16,
  epochs = 5
  
  output_num_classes = 2
  
  K.set_image_data_format('channels_last')
  model = applications.VGG19(weights=&quot;imagenet&quot;, include_top=False, input_shape=(img_width, img_height, 3))
  
  model.summary()
  
  x = model.output
  x = Flatten()(x)
  x = Dense(1024, activation=&quot;relu&quot;)(x)
  x = Dropout(0.5)(x)
  x = Dense(1024, activation=&quot;relu&quot;)(x)
  predictions = Dense(output_num_classes, activation=&quot;softmax&quot;)(x)
  
  model_final = Model(inputs=model.input, outputs=predictions)
  model_final.compile(loss=&quot;categorical_crossentropy&quot;, 
                      optimizer=optimizers.SGD(learning_rate=0.0001, momentum=0.9),
                      metrics=['accuracy'])
  </code></pre>
  <pre><code>train_datagen = ImageDataGenerator(rescale=1./255,
                                     zoom_range=0.3,
                                     width_shift_range=0.3,
                                     height_shift_range=0.3,
                                     rotation_range=30,
                                     horizontal_flip=True,
                                     fill_mode='nearest')
  
  train_generator = train_datagen.flow_from_directory(train_data_dir,
                                                      target_size=(img_height, img_width),
                                                      batch_size=batch_size,
                                                      class_mode='categorical')
  
  validation_datagen = ImageDataGenerator(rescale=1./255,
                                     zoom_range=0.3,
                                     width_shift_range=0.3,
                                     height_shift_range=0.3,
                                     rotation_range=30,
                                     horizontal_flip=True,
                                     fill_mode='nearest')
  
  validation_generator = validation_datagen.flow_from_directory(validation_data_dir,
                                                                target_size=(img_height, img_width),
                                                                batch_size = batch_size,
                                                                class_mode='categorical')
  
  </code></pre>
  <p>The code above is before fitting.</p>
  <pre><code>model_final.fit_generator(train_generator, 
                            steps_per_epoch=nb_train_samples,
                            epochs = epochs,
                            validation_data = validation_generator,
                            validation_steps = nb_validation_samples)
  
  /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:1844: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.
    warnings.warn('`Model.fit_generator` is deprecated and '
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-87-b195f52ce8fb&gt; in &lt;module&gt;()
        3                           epochs = epochs,
        4                           validation_data = validation_generator,
  ----&gt; 5                           validation_steps = nb_validation_samples)
  
  /usr/local/lib/python3.7/dist-packages/keras_preprocessing/image/iterator.py in __len__(self)
       66 
       67     def __len__(self):
  ---&gt; 68         return (self.n + self.batch_size - 1) // self.batch_size  # round up
       69 
       70     def on_epoch_end(self):
  
  TypeError: unsupported operand type(s) for +: 'int' and 'tuple' ```
  </code></pre>