Challenge - 5 Problems
Feature Map Visualization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output shape of feature maps after convolution
Consider a PyTorch convolutional layer defined as
conv = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1). If the input tensor has shape (1, 3, 64, 64), what will be the shape of the output feature map after applying conv?PyTorch
import torch import torch.nn as nn conv = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1) input_tensor = torch.randn(1, 3, 64, 64) output = conv(input_tensor) print(output.shape)
Attempts:
2 left
💡 Hint
Remember that padding=1 keeps the spatial size same when kernel_size=3 and stride=1.
✗ Incorrect
The formula for output size is ((W - K + 2P) / S) + 1. Here, W=64, K=3, P=1, S=1, so output size is 64. The number of output channels is 16.
🧠 Conceptual
intermediate1:30remaining
Purpose of feature map visualization in CNNs
Why do we visualize feature maps in convolutional neural networks (CNNs)?
Attempts:
2 left
💡 Hint
Think about what feature maps represent inside a CNN.
✗ Incorrect
Feature maps show the activations after convolution layers, revealing what features the network focuses on, like edges or textures.
❓ Metrics
advanced1:30remaining
Interpreting feature map activation statistics
After visualizing feature maps from a CNN layer, you notice most activations are near zero except a few very high values. What does this indicate about the layer's behavior?
Attempts:
2 left
💡 Hint
Sparse activations mean only some neurons respond strongly.
✗ Incorrect
Sparse activations mean the layer detects specific features strongly while ignoring others, which is common and often desirable.
🔧 Debug
advanced2:00remaining
Why does feature map visualization show a blank image?
You wrote code to visualize feature maps from a CNN layer but the output images are all black. Which of the following is the most likely cause?
PyTorch
import matplotlib.pyplot as plt import torch # feature_maps is a tensor of shape (1, 16, 64, 64) feature_maps = torch.randn(1, 16, 64, 64) * 0.01 plt.imshow(feature_maps[0, 0].detach().numpy()) plt.show()
Attempts:
2 left
💡 Hint
Check the range of values before plotting images.
✗ Incorrect
If values are very small and not scaled, the image appears black. Normalizing or scaling values helps visualize.
❓ Model Choice
expert2:30remaining
Choosing a layer for meaningful feature map visualization
You want to visualize feature maps that show clear edges and textures from an image classification CNN. Which layer is best to choose?
Attempts:
2 left
💡 Hint
Early layers detect simple features like edges.
✗ Incorrect
Early convolutional layers capture basic features like edges and textures, making their feature maps visually meaningful.