Search code examples
tensorflowkerasdeep-learningconv-neural-network

UnimplementedError: Fused conv implementation does not support grouped convolutions for now


I am trying to build a CNN model to recognise human sketch using the TU-Berlin dataset. I downloaded the png zip file, imported the data to Google Colab and then split the data into train-test folders. Here is the model:

model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(filters = 64, kernel_size = (5,5),padding = 'Same', 
                 activation ='relu', input_shape = target_dims),
    tf.keras.layers.Conv2D(filters = 64, kernel_size = (5,5),padding = 'Same', 
                 activation ='relu'),
    tf.keras.layers.MaxPool2D(pool_size=(2,2)),
    tf.keras.layers.Dropout(0.25),

    tf.keras.layers.Conv2D(filters = 128, kernel_size = (3,3),padding = 'Same', 
                 activation ='relu'),
    tf.keras.layers.Conv2D(filters = 128, kernel_size = (3,3),padding = 'Same', 
                 activation ='relu'),
    tf.keras.layers.MaxPool2D(pool_size=(2,2), strides=(2,2)),
    tf.keras.layers.Dropout(0.25),

    tf.keras.layers.Conv2D(256, kernel_size=4, strides=1, activation='relu', padding='same'),
    tf.keras.layers.Conv2D(256, kernel_size=4, strides=2, activation='relu', padding='same'),
    tf.keras.layers.Dropout(0.25),

    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(512, activation = "relu"),
    tf.keras.layers.Dropout(0.5),
    tf.keras.layers.Dense(n_classes, activation= "softmax")
])

model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=["accuracy"])

model.fit_generator(train_generator, epochs=10, validation_data=val_generator)

And I am getting the following error:

UnimplementedError:  Fused conv implementation does not support grouped convolutions for now.
     [[node sequential/conv2d/Relu (defined at <ipython-input-9-36d4624b896d>:1) ]] [Op:__inference_train_function_1358]

Function call stack:
train_function

I would be grateful to any kind of help that will solve this issue. Thank you.

(PS - I am running Tensorflow 2.2.0 and no GPU)


Solution

  • I had this same error using the facial expression recognition dataset, here's how i solved this same error.

    From what i understand the dataset is gray color, when you use ImageDataGenerator of tensorflow and flow_from_directory to generate the train and validation set,

    you need to specify the color_mode as grayscale or rgb based on the dataset/images, here it will be 'grayscale',

    in the model the first layer Conv2D the input_shape should be

    input_shape = (height, width, 1), 1 because its grayscale.