Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 465
arghyab0 Avatar asked May 14 '20 11:05

arghyab0


3 Answers

I had a similar error, the problem was with the number of channels for my image and the number of channels I specified in the model. So check the number of dimension of your image and check the value specified in the input shape ensure they are the same

like image 163
grande_cifer Avatar answered Jan 12 '23 10:01

grande_cifer


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.

like image 39
VikasKM Avatar answered Jan 12 '23 08:01

VikasKM


Just mention the color_mode="grayscale" in flow from directory and check your model input (height,width,1).

like image 24
Ajay Nazirkar Avatar answered Jan 12 '23 09:01

Ajay Nazirkar