Deep Learning Mastery Quiz

10:00

Tensors, training, regularisation, CNNs, sequence models, transformers and deployment in PyTorch. · 10 questions

Question 1 of 10
What does calling `loss.backward()` do in PyTorch?
Question 2 of 10
Which layer type is best suited to capturing local spatial patterns in images?
Question 3 of 10
Why is `optimizer.zero_grad()` called at the start of each training step?
Question 4 of 10
What does `model.eval()` change?
Question 5 of 10
What does this code print?
import torch
x = torch.tensor(3.0, requires_grad=True)
y = x ** 2 + 4 * x
y.backward()
print(x.grad)
Question 6 of 10
What is the output shape?
import torch, torch.nn as nn
conv = nn.Conv2d(3, 16, kernel_size=3, padding=1)
x = torch.randn(8, 3, 64, 64)
print(conv(x).shape)
Question 7 of 10
What inputs does `nn.CrossEntropyLoss` expect for multi-class classification?
Question 8 of 10
You have 400 labelled images across 4 classes. What is the best first approach?
Question 9 of 10
Why are attention scores divided by the square root of the key dimension?
Question 10 of 10
What shapes are printed?
import torch, torch.nn as nn
lstm = nn.LSTM(input_size=10, hidden_size=32, num_layers=2, batch_first=True)
x = torch.randn(4, 15, 10)
out, (h, c) = lstm(x)
print(out.shape, h.shape)