What is the default kernel-size, Zero-padding and stride for keras.layers.Conv2D?

11.2k views Asked by At

What are the default Kernel-Size, Zero-Padding, and Stride arguments in Conv2D (keras.layers.Conv2D)? What happens if these arguments are not specified?

2

There are 2 answers

0
Mete Han Kahraman On BEST ANSWER

You can find the documentation here: https://keras.io/layers/convolutional/

In python you can give default values for parameters of a function, If you don't specify these parameters while calling the function, defaults are used instead.

In the link above you'll find that Conv2D has the parameters:

filters, kernel_size, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 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

only filters and kernel_size parameters must be given, others are optional or has default values next to them.

0
Kaveh On

As this link suggests, it has a structure like this:

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 have to specify filters and kernel_size. These parameters have no default.

Default padding is valid, which means no zero-padding, and the default strides is (1,1).