Complete the code to create a 2D convolutional layer with stride 1.
conv_layer = tf.keras.layers.Conv2D(filters=32, kernel_size=3, strides=[1], padding='same')
The stride parameter controls how the filter moves over the input. A stride of 1 means the filter moves one pixel at a time.
Complete the code to apply 'valid' padding in a Conv2D layer.
conv_layer = tf.keras.layers.Conv2D(filters=64, kernel_size=5, strides=1, padding=[1])
'valid' padding means no padding is added, so the output size shrinks depending on the kernel size.
Fix the error in the stride parameter to correctly create a Conv2D layer with stride 2.
conv_layer = tf.keras.layers.Conv2D(filters=16, kernel_size=3, strides=[1], padding='same')
In TensorFlow, strides can be an integer or a tuple. For 2D convolution, a tuple like (2, 2) is preferred to specify stride in height and width.
Fill both blanks to create a Conv2D layer with kernel size 3 and stride 2.
conv_layer = tf.keras.layers.Conv2D(filters=10, kernel_size=[1], strides=[2], padding='valid')
The kernel size is 3 (can be int or tuple), and stride is (2, 2) to move two pixels in height and width.
Fill all three blanks to create a Conv2D layer with kernel size (5,5), stride 1, and 'same' padding.
conv_layer = tf.keras.layers.Conv2D(filters=20, kernel_size=[1], strides=[2], padding=[3])
Kernel size is (5,5) for a 5x5 filter, stride 1 moves one pixel at a time, and 'same' padding keeps output size same as input.