Challenge - 5 Problems
Sequential Model Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple PyTorch Sequential model
What is the output shape of the tensor after passing through this PyTorch Sequential model?
PyTorch
import torch import torch.nn as nn model = nn.Sequential( nn.Linear(10, 5), nn.ReLU(), nn.Linear(5, 2) ) x = torch.randn(3, 10) out = model(x) print(out.shape)
Attempts:
2 left
💡 Hint
Remember the input batch size and the output size of the last Linear layer.
✗ Incorrect
The input tensor has shape (3, 10). The first Linear layer outputs (3, 5), then ReLU keeps the shape, and the last Linear layer outputs (3, 2). So the final output shape is (3, 2).
❓ Model Choice
intermediate2:00remaining
Choosing the correct Sequential model for image flattening
Which PyTorch Sequential model correctly flattens a 28x28 grayscale image and outputs 10 class scores?
Attempts:
2 left
💡 Hint
Flatten should come before Linear to convert 2D image to 1D vector.
✗ Incorrect
Option A first flattens the 28x28 image into a vector of length 784, then applies a Linear layer to output 10 scores. Option A tries to flatten after Linear which is invalid. Option A uses Conv2d which changes shape differently. Option A outputs wrong size.
❓ Hyperparameter
advanced2:00remaining
Effect of changing hidden layer size in Sequential model
You have a Sequential model: nn.Sequential(nn.Linear(20, 50), nn.ReLU(), nn.Linear(50, 5)). What happens if you change the hidden layer size from 50 to 10?
Attempts:
2 left
💡 Hint
Hidden layer size controls model capacity and parameter count.
✗ Incorrect
Reducing hidden layer size from 50 to 10 reduces parameters, which can speed training but may reduce model capacity, risking underfitting. Output size remains 5, input size stays 20.
🔧 Debug
advanced2:00remaining
Identify the error in this Sequential model code
What error will this PyTorch code raise?
PyTorch
import torch.nn as nn model = nn.Sequential( nn.Linear(10, 20), nn.ReLU(), nn.Linear(15, 5) )
Attempts:
2 left
💡 Hint
Check the output size of first Linear and input size of second Linear.
✗ Incorrect
The first Linear outputs size 20, but the second Linear expects input size 15, causing a runtime size mismatch error.
❓ Metrics
expert3:00remaining
Interpreting training loss and accuracy from Sequential model training
After training a PyTorch Sequential model for classification, you observe the following metrics: training loss decreases steadily, but training accuracy stays around 50%. What is the most likely explanation?
Attempts:
2 left
💡 Hint
Loss decreasing but accuracy stuck means model predictions improve but not enough to classify correctly.
✗ Incorrect
If loss decreases but accuracy stays low, the model may be learning something but not enough to classify well. This can happen if labels are wrong or model capacity is insufficient.