0
0
TensorFlowml~10 mins

Conv2D layers in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Conv2D layer with 32 filters.

TensorFlow
layer = tf.keras.layers.Conv2D([1], kernel_size=(3,3), activation='relu')
Drag options to blanks, or click blank then click option'
A16
B64
C32
D128
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a very large number of filters can slow training.
Using zero or negative numbers causes errors.
2fill in blank
medium

Complete the code to add padding to the Conv2D layer to keep the output size same as input.

TensorFlow
layer = tf.keras.layers.Conv2D(32, kernel_size=(3,3), padding=[1], activation='relu')
Drag options to blanks, or click blank then click option'
A'valid'
B'same'
C'full'
D'none'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'valid' padding reduces output size.
Using invalid strings causes errors.
3fill in blank
hard

Fix the error in the Conv2D layer that causes a shape mismatch.

TensorFlow
layer = tf.keras.layers.Conv2D(64, kernel_size=[1], activation='relu')
Drag options to blanks, or click blank then click option'
A(3, 3)
B3
C(5, 5)
D[3, 3]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single integer instead of a tuple.
Using square brackets instead of parentheses.
4fill in blank
hard

Fill both blanks to create a Conv2D layer with 16 filters and stride of 2.

TensorFlow
layer = tf.keras.layers.Conv2D([1], kernel_size=(3,3), strides=[2], activation='relu')
Drag options to blanks, or click blank then click option'
A16
B(1, 1)
C(2, 2)
D32
Attempts:
3 left
💡 Hint
Common Mistakes
Using stride (1, 1) does not reduce output size.
Choosing too many filters can slow training.
5fill in blank
hard

Fill all three blanks to create a Conv2D layer with 64 filters, kernel size (5,5), and 'valid' padding.

TensorFlow
layer = tf.keras.layers.Conv2D([1], kernel_size=[2], padding=[3], activation='relu')
Drag options to blanks, or click blank then click option'
A32
B(5, 5)
C'valid'
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'same' padding when 'valid' is required.
Passing kernel size as a single integer.