Week 1, assignment 2 (Convolution_model_Application)

in the function convolutional_model(input_shape), when i put the value of
Z1= tf.keras.layers.Conv2D(input_shape, filters = 8, kernel_size = (4,4), strides=1, padding=‘same’)
i get the error:
init() got multiple values for argument ‘filters’

Can anyone help me out, what have i done wrong and how can i correct it?

Hi @pg7064,

The tf.keras.layers.Conv2D function takes filters as the first argument, so when you do:

Z1 = tf.keras.layers.Conv2D(input_shape, filters = 8 ...)

You are actually passing filters twice: Once as a positional argument and another as a keyword argument.
Conv2D doesn’t take input_shape as parameters:

tf.keras.layers.Conv2D(filters, kernel_size, strides=(1, 1), padding='valid',    data_format=None, dilation_rate=(1, 1), groups=1, activation=None,  use_bias=True, kernel_initializer='glorot_uniform',    bias_initializer='zeros', kernel_regularizer=None,    bias_regularizer=None, activity_regularizer=None, kernel_constraint=None,    bias_constraint=None, **kwargs)

You can see the documentation here: tf.keras.layers.Conv2D  |  TensorFlow Core v2.6.0

Hope that helps!


Thanks! It works now