Challenge - 5 Problems
PyTorch Ecosystem Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding PyTorch's Core Components
Which of the following is NOT a core component of the PyTorch ecosystem?
Attempts:
2 left
💡 Hint
Think about which library is external and not part of PyTorch itself.
✗ Incorrect
NumPy is a separate library for numerical computing in Python. While PyTorch tensors can interoperate with NumPy arrays, NumPy is not a core component of the PyTorch ecosystem.
❓ Predict Output
intermediate2:00remaining
Output of PyTorch Model Training Loop
What will be the printed output after running this PyTorch training loop snippet?
PyTorch
import torch import torch.nn as nn model = nn.Linear(2, 1) criterion = nn.MSELoss() optimizer = torch.optim.SGD(model.parameters(), lr=0.1) inputs = torch.tensor([[1.0, 2.0]]) targets = torch.tensor([[1.0]]) optimizer.zero_grad() outputs = model(inputs) loss = criterion(outputs, targets) loss.backward() optimizer.step() print(round(loss.item(), 4))
Attempts:
2 left
💡 Hint
The loss is the mean squared error between model output and target before the optimizer step.
✗ Incorrect
The initial weights are random, so the output will not match the target exactly. The MSE loss will be a positive value around 0.5 for this simple input and target.
❓ Model Choice
advanced2:00remaining
Choosing the Right PyTorch Ecosystem Library
You want to train a natural language processing model using pre-built datasets and tokenizers. Which PyTorch ecosystem library should you use?
Attempts:
2 left
💡 Hint
Think about which library focuses on text data.
✗ Incorrect
TorchText provides tools for text processing, datasets, and tokenization for NLP tasks within the PyTorch ecosystem.
❓ Hyperparameter
advanced2:00remaining
Effect of Learning Rate in PyTorch Optimizer
If you increase the learning rate in a PyTorch optimizer too much, what is the most likely effect on training?
Attempts:
2 left
💡 Hint
Think about what happens if steps are too large when trying to find a minimum.
✗ Incorrect
A very high learning rate can cause the model to overshoot minima, causing unstable training and possibly divergence.
❓ Metrics
expert2:00remaining
Calculating Accuracy from PyTorch Model Outputs
Given a batch of model outputs as logits and true labels, which code snippet correctly computes the classification accuracy in PyTorch?
PyTorch
outputs = torch.tensor([[2.0, 1.0, 0.1], [0.5, 2.5, 0.3], [1.2, 0.7, 2.1]]) labels = torch.tensor([0, 1, 2])
Attempts:
2 left
💡 Hint
Check how to get predicted class indices and how to compute mean accuracy.
✗ Incorrect
Using argmax over dimension 1 gives predicted class indices per sample. Comparing with labels and taking the mean of correct predictions gives accuracy.