0
0
TensorFlowml~20 mins

Pooling layers (MaxPool, AvgPool) in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pooling Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output shape after MaxPooling2D layer
Given the following TensorFlow code, what is the shape of the output tensor after applying the MaxPooling2D layer?
TensorFlow
import tensorflow as tf
input_tensor = tf.random.uniform(shape=(1, 28, 28, 3))
max_pool = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2)
output_tensor = max_pool(input_tensor)
output_shape = output_tensor.shape
A(1, 7, 7, 3)
B(1, 14, 14, 3)
C(1, 28, 28, 3)
D(1, 13, 13, 3)
Attempts:
2 left
💡 Hint
Remember that MaxPooling2D with pool_size (2,2) and stride 2 reduces each spatial dimension by half when padding is 'valid'.
🧠 Conceptual
intermediate
1:30remaining
Difference between MaxPooling and AveragePooling
Which statement correctly describes the difference between MaxPooling and AveragePooling layers in convolutional neural networks?
AMaxPooling selects the maximum value in each pooling window, while AveragePooling computes the average value in each pooling window.
BMaxPooling computes the average value in each pooling window, while AveragePooling selects the maximum value.
CBoth MaxPooling and AveragePooling select the minimum value in each pooling window.
DMaxPooling and AveragePooling both compute the sum of values in each pooling window.
Attempts:
2 left
💡 Hint
Think about how each pooling method summarizes the values in a small region.
Hyperparameter
advanced
2:00remaining
Effect of stride on output size in pooling layers
If you apply a MaxPooling2D layer with pool_size=(3,3) and stride=1 on an input tensor of shape (1, 10, 10, 1) with padding='valid', what will be the spatial dimensions (height and width) of the output?
A(8, 8)
B(7, 7)
C(10, 10)
D(9, 9)
Attempts:
2 left
💡 Hint
Use the formula: output_size = (input_size - pool_size) / stride + 1
🔧 Debug
advanced
2:00remaining
Identifying error in pooling layer usage
What error will occur when running the following TensorFlow code snippet?
TensorFlow
import tensorflow as tf
input_tensor = tf.random.uniform(shape=(1, 28, 28, 3))
max_pool = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=3)
output_tensor = max_pool(input_tensor)
print(output_tensor.shape)
AValueError due to stride larger than input dimension
BNo error; output shape will be (1, 13, 13, 3)
CTypeError because strides must be a tuple, not an integer
DNo error; output shape will be (1, 9, 9, 3)
Attempts:
2 left
💡 Hint
Check if strides can be an integer and how output shape is computed.
Model Choice
expert
2:30remaining
Choosing pooling layer for noise robustness
You want to build a convolutional neural network that is robust to small noisy activations in feature maps. Which pooling layer choice is best to reduce the effect of noise?
ANo pooling layer, to preserve all activations including noise
BMaxPooling, because it selects the strongest activation which may amplify noise
CAveragePooling, because it smooths activations and reduces noise impact
DGlobalMaxPooling, because it selects the maximum activation over the entire feature map
Attempts:
2 left
💡 Hint
Consider how each pooling method treats small noisy values.