0
0
PyTorchml~10 mins

Num workers for parallel loading in PyTorch - Interactive Code Practice

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

Complete the code to set the number of workers for parallel data loading in PyTorch.

PyTorch
train_loader = DataLoader(dataset, batch_size=32, shuffle=True, num_workers=[1])
Drag options to blanks, or click blank then click option'
A0
B4
C-1
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative numbers for num_workers causes errors.
Setting num_workers to None is invalid.
2fill in blank
medium

Complete the code to enable parallel data loading with 2 workers in PyTorch.

PyTorch
train_loader = DataLoader(dataset, batch_size=64, shuffle=True, num_workers=[1])
Drag options to blanks, or click blank then click option'
A0
B1
C8
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Setting num_workers to 0 disables parallel loading.
Using too many workers can slow down the system.
3fill in blank
hard

Fix the error in the code by choosing the correct num_workers value for DataLoader.

PyTorch
loader = DataLoader(dataset, batch_size=16, shuffle=False, num_workers=[1])
Drag options to blanks, or click blank then click option'
A0
BNone
C3
D-2
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative numbers like -2 causes errors.
Passing None is not accepted.
4fill in blank
hard

Fill both blanks to create a DataLoader with batch size 128 and 6 parallel workers.

PyTorch
loader = DataLoader(dataset, batch_size=[1], shuffle=True, num_workers=[2])
Drag options to blanks, or click blank then click option'
A128
B64
C6
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing batch size with num_workers values.
Using too many workers causing slowdowns.
5fill in blank
hard

Fill all three blanks to create a DataLoader with batch size 256, shuffle disabled, and 8 workers.

PyTorch
loader = DataLoader(dataset, batch_size=[1], shuffle=[2], num_workers=[3])
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C8
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Setting shuffle to True when it should be False.
Using invalid types for batch size or num_workers.