0
0
Computer Visionml~10 mins

Model comparison in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a pre-trained model for image classification.

Computer Vision
from torchvision import models
model = models.[1](pretrained=True)
Drag options to blanks, or click blank then click option'
Atrain
Bfit
Cresnet18
Devaluate
Attempts:
3 left
💡 Hint
Common Mistakes
Using training or evaluation functions instead of model names.
2fill in blank
medium

Complete the code to set the model to evaluation mode before making predictions.

Computer Vision
model.[1]()
Drag options to blanks, or click blank then click option'
Aeval
Bfit
Ctrain
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using train() instead of eval().
3fill in blank
hard

Fix the error in the code to compute accuracy from model outputs and labels.

Computer Vision
correct = (outputs.argmax(dim=1) [1] labels).sum().item()
accuracy = correct / labels.size(0)
Drag options to blanks, or click blank then click option'
A!=
B=
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment = instead of comparison ==.
4fill in blank
hard

Fill both blanks to create a dictionary of model names and their validation accuracies.

Computer Vision
results = { '[1]': val_acc1, '[2]': val_acc2 }
Drag options to blanks, or click blank then click option'
AResNet18
BVGG16
CAlexNet
DDenseNet
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or misspelled model names.
5fill in blank
hard

Fill all three blanks to complete the code that compares two models' accuracies and prints the better one.

Computer Vision
if results['[1]'] [2] results['[3]']:
    print('Better model: ResNet18')
else:
    print('Better model: VGG16')
Drag options to blanks, or click blank then click option'
AResNet18
B>
CVGG16
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping model names or using wrong comparison operators.