Stack Exchange
Need help correcting errors after keras model.fit_generator is ran
I am new to convolution neural network and python .My model is training correctly but when I add fit_genarator, I'm getting errors as mentioned in the output section.
import keras,os
from keras.models import Sequential
from keras.layers import Dense, Conv2D, MaxPool2D , Flatten
from keras.preprocessing.image import ImageDataGenerator
import numpy as np
Classifier = Sequential()

Classifier.add(Conv2D(input_shape=(64,3,3),filters=32,kernel_size=(3,3),padding="same", activation="relu"))

Classifier.add(MaxPool2D(pool_size= (2,2),strides=(2,2)))
Classifier.add(Flatten())
Classifier.add(Dense(  units=128, activation="relu"))
Classifier.add(Dense( activation="sigmoid", units=1))
Classifier.compile(optimizer="adam",
                   loss="binary_crossentropy",
                   metric=['accuracy'] )

train_datagen = ImageDataGenerator(
        rescale=1./255,
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(
        'E:/P14-Convolutional-Neural-Networks/Convolutional_Neural_Networks/dataset/training_set',
        target_size=(224, 224),
        batch_size=32,
        class_mode='binary')

validation_generator = test_datagen.flow_from_directory(
        'E:/P14-Convolutional-Neural-Networks/Convolutional_Neural_Networks/dataset/test_set',
        target_size=(224, 224),
        batch_size=32,
        class_mode='binary')

Classifier.fit_generator(
        train_generator,
        steps_per_epoch=8000,
        epochs=25,
        validation_data=validation_generator,
        validation_steps=2000)
 

The output is:
runfile('E:/vgg_16/code.py', wdir='E:/vgg_16')
Found 8000 images belonging to 2 classes.
Found 2000 images belonging to 2 classes.
Traceback (most recent call last):

  File "<ipython-input-57-f246d1da43d0>", line 1, in <module>
    runfile('E:/vgg_16/code.py', wdir='E:/vgg_16')

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "E:/vgg_16/code.py", line 61, in <module>
    validation_steps=2000)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\keras\engine\training.py", line 1732, in fit_generator
    initial_epoch=initial_epoch)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\keras\engine\training_generator.py", line 42, in fit_generator
    model._make_train_function()

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\keras\engine\training.py", line 333, in _make_train_function
    **self._function_kwargs)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 3009, in function
    **kwargs)

  File "C:\Users\Qandeel\Anaconda3\lib\site-packages\tensorflow_core\python\keras\backend.py", line 3772, in function
    'eager execution. You passed: %s' % (kwargs,))

ValueError: Session keyword arguments are not support during eager execution. You passed: {'metric': ['accuracy']}


Python documentation explains exception.ValueError best: 

Raised when an operation or function receives an argument that has the
  right type but an inappropriate value, and the situation is not
  described by a more precise exception such as IndexError.

To answer your question, you have metric argument in your model's compile method and it is not supported for fit_generator method as per the official keras document.
Remove metric and try again to get past it.
fit_generator(generator, steps_per_epoch=None, epochs=1, 
              verbose=1, callbacks=None, validation_data=None,
              validation_steps=None, validation_freq=1, class_weight=None, 
              max_queue_size=10, workers=1,
              use_multiprocessing=False, shuffle=True, initial_epoch=0)

