0
0
Computer Visionml~10 mins

Data loading with torchvision 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 import the torchvision datasets module.

Computer Vision
from torchvision import [1]
Drag options to blanks, or click blank then click option'
Amodels
Bdatasets
Ctransforms
Dutils
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'models' instead of 'datasets'.
Importing 'transforms' when datasets are needed.
2fill in blank
medium

Complete the code to load the MNIST training dataset with torchvision.

Computer Vision
train_data = datasets.MNIST(root='./data', train=[1], download=True)
Drag options to blanks, or click blank then click option'
A1
BFalse
C'yes'
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'yes' instead of boolean True.
Using 1 instead of True.
3fill in blank
hard

Fix the error in the code to apply a transform that converts images to tensors.

Computer Vision
from torchvision import transforms

transform = transforms.[1]()
train_data = datasets.MNIST(root='./data', train=True, download=True, transform=transform)
Drag options to blanks, or click blank then click option'
AToTensor
Bto_tensor
CtoTensor
DTensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'to_tensor' which does not exist.
Using 'Tensor' which is not a transform class.
4fill in blank
hard

Fill both blanks to create a DataLoader for the training data with batch size 64 and shuffling enabled.

Computer Vision
from torch.utils.data import DataLoader

train_loader = DataLoader(train_data, batch_size=[1], shuffle=[2])
Drag options to blanks, or click blank then click option'
A64
BTrue
C32
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using batch size 32 instead of 64.
Setting shuffle to False which disables randomization.
5fill in blank
hard

Fill all three blanks to create a transform pipeline that resizes images to 28x28, converts to tensor, and normalizes with mean 0.5 and std 0.5.

Computer Vision
transform = transforms.Compose([
    transforms.Resize(([1], [2])),
    transforms.ToTensor(),
    transforms.Normalize(mean=[[3]], std=[0.5])
])
Drag options to blanks, or click blank then click option'
A28
B0.5
C32
D0.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 32 instead of 28 for resize dimensions.
Using 0.0 for mean which is not balanced normalization.