0
0
TensorFlowml~10 mins

Pooling layers (MaxPool, AvgPool) 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 add a MaxPooling2D layer with pool size 2x2.

TensorFlow
model.add(tf.keras.layers.MaxPooling2D(pool_size=[1]))
Drag options to blanks, or click blank then click option'
A(4, 4)
B(2, 2)
C(3, 3)
D(1, 1)
Attempts:
3 left
💡 Hint
Common Mistakes
Using pool_size (1, 1) which does not reduce size.
Confusing pool_size with strides.
2fill in blank
medium

Complete the code to add an AveragePooling2D layer with pool size 3x3.

TensorFlow
model.add(tf.keras.layers.AveragePooling2D(pool_size=[1]))
Drag options to blanks, or click blank then click option'
A(4, 4)
B(2, 2)
C(1, 1)
D(3, 3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using MaxPooling2D instead of AveragePooling2D.
Using wrong pool_size like (2, 2) instead of (3, 3).
3fill in blank
hard

Fix the error in the code to correctly add a MaxPooling2D layer with stride 2.

TensorFlow
model.add(tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=[1]))
Drag options to blanks, or click blank then click option'
A(2, 2)
B(1, 1)
C(3, 3)
D(4, 4)
Attempts:
3 left
💡 Hint
Common Mistakes
Setting strides to (1, 1) which does not downsample.
Using strides larger than pool_size causing skipped regions.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.

TensorFlow
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword.startswith('a')
Dword.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.upper() as value which changes the word instead of length.
Using word.startswith('a') as condition which filters differently.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension mapping uppercase words to their lengths if length is greater than 4.

TensorFlow
{ [1]: [2] for word in words if [3] }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Clen(word) > 4
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() as key instead of uppercase.
Using len(word) < 4 as condition which filters incorrectly.