anne26
anne26

Reputation: 13

TypeError: `Conv2D` can accept only 2 positional arguments ('filters', 'kernel_size'), but you passed the following positional arguments:

I'm trying to run a CNN, but I get this message:

TypeError: `Conv2D` can accept only 2 positional arguments ('filters', 'kernel_size'), but you passed the following positional arguments: [64, (3, 3), (1, 1)]

My code is:

num_filters_conv1 = 64
kernel_size_conv1 = (3,3)
stride_conv1 = (1,1)
padding_conv1 = 'valid'
input_shape = (rows, cols, 1)

model.add(Conv2D(num_filters_conv1, kernel_size_conv1, stride_conv1, padding_conv1, activation='relu', input_shape=input_shape))

Anyone knows what's going on? Why are the kernel and padding not supported?

Upvotes: 1

Views: 481

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169484

Strides and padding are keyword arguments.
Reference: https://keras.io/backend/#conv2d
Try instead:

model.add(Conv2D(num_filters_conv1, kernel_size_conv1, 
                 strides=stride_conv1, padding=padding_conv1, 
                 activation='relu', input_shape=input_shape))

Upvotes: 2

Related Questions