0
0
PyTorchml~20 mins

Why pre-trained models accelerate development in PyTorch - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pre-trained Model Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do pre-trained models reduce training time?

Pre-trained models have already learned useful features from large datasets. How does this help reduce the time needed to train a new model?

AThey require more data to train but finish faster because of parallel processing.
BThey use simpler algorithms that run faster on the computer.
CThey skip the training process entirely and only do inference.
DThey start with weights that already capture important patterns, so less training is needed to adapt to a new task.
Attempts:
2 left
💡 Hint

Think about what it means to start learning from scratch versus starting with some knowledge.

Predict Output
intermediate
2:00remaining
Output of fine-tuning a pre-trained model

Consider this PyTorch code snippet that loads a pre-trained ResNet18 model and fine-tunes it on a new dataset. What will be the output of the printed statement?

PyTorch
import torch
import torchvision.models as models

model = models.resnet18(pretrained=True)
for param in model.parameters():
    param.requires_grad = False
model.fc = torch.nn.Linear(model.fc.in_features, 10)  # New output layer for 10 classes

trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad)
print(trainable_params)
A5130
B20480
C1000
D0
Attempts:
2 left
💡 Hint

Only the new final layer's parameters are trainable. Calculate the number of parameters in the new linear layer.

Model Choice
advanced
2:00remaining
Choosing a pre-trained model for image classification

You want to build an image classifier for a small dataset of 500 images. Which pre-trained model choice will likely give the best balance of accuracy and training speed?

AA random initialized model with no pre-training
BA small model like MobileNetV2 trained on ImageNet
CA model trained from scratch on your 500 images
DA large model like ResNet152 trained on ImageNet
Attempts:
2 left
💡 Hint

Consider model size, dataset size, and training time.

Hyperparameter
advanced
2:00remaining
Best learning rate strategy when fine-tuning pre-trained models

When fine-tuning a pre-trained model, which learning rate strategy is usually best?

AUse a high learning rate for all layers to speed up training
BFreeze all layers and do not update any weights
CUse a low learning rate for pre-trained layers and a higher rate for new layers
DUse the same learning rate for all layers regardless of pre-training
Attempts:
2 left
💡 Hint

Think about how much you want to change the pre-trained weights versus new layers.

Metrics
expert
2:00remaining
Interpreting training metrics of a fine-tuned model

You fine-tune a pre-trained model on a new task. After 10 epochs, training accuracy is 98% but validation accuracy is 70%. What does this indicate?

AThe model is overfitting the training data and not generalizing well.
BThe model is underfitting and needs more training epochs.
CThe validation data is too easy compared to training data.
DThe pre-trained model is not suitable for this task.
Attempts:
2 left
💡 Hint

Think about what it means when training accuracy is high but validation accuracy is low.