PyTorch Deep Learning
- 30Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is the core philosophy of the Learn PyTorch for Deep Learning course?
Learn by writing code. The motto is: 'If in doubt, run the code.'
Or swipe the card
30 cards
What is the core philosophy of the Learn PyTorch for Deep Learning course?
Learn by writing code. The motto is: 'If in doubt, run the code.'
Where are the course materials available for free?
Course materials are on GitHub (mrdbourke/pytorch-deep-learning) and an online book version at learnpytorch.io.
What is the definition of machine learning according to this course?
Turning data (anything: images, text, numbers) into numbers and finding patterns in those numbers.
How does supervised machine learning differ from traditional programming?
Traditional: Inputs + Rules → Outputs. Supervised ML: Inputs + Desired Outputs → Rules (the algorithm learns the rules/patterns).
When should you NOT use machine learning/deep learning according to Google's Rule #1?
If you can build a simple, reliable rule-based system, do that instead. Also avoid when: explainability is needed, errors are unacceptable, or you don't have much data.
What type of data is machine learning (shallow algorithms) best for compared to deep learning?
ML (shallow algorithms) is best for structured data (tables of numbers). Deep learning is best for unstructured data (images, text, audio).
What are the three learning paradigms covered in this course?
Supervised learning, unsupervised/self-supervised learning, and transfer learning. The course focuses on supervised and transfer learning.
What is PyTorch and who developed it?
PyTorch is an open-source deep learning framework developed by Facebook/Meta, used for writing fast deep learning code in Python accelerated by GPUs.
What is a tensor in PyTorch?
A tensor is the fundamental building block of data in PyTorch — a numerical representation that can be a scalar, vector, matrix, or higher-dimensional array.
What are the core steps of the PyTorch workflow?
- Data (preparing and loading) 2. Build/pick a model (including loss function and optimizer) 3. Fit model to data (training loop) 4. Make predictions 5. Evaluate 6. Improve through experimentation 7. Save and load model.
How is a simple linear regression model built in PyTorch?
Subclass
torch.nn.Module, define parameters withnn.Parameter()in__init__, and implement the forward pass inforward()(e.g.,y = weight * X + bias).What loss function and optimizer are typically used for a regression problem in PyTorch?
Loss function:
nn.L1Loss()(Mean Absolute Error). Optimizer:torch.optim.SGD()with a learning rate hyperparameter (e.g., 0.01).What are the five steps in the training loop for each epoch?
- Forward pass:
y_pred = model(X_train)2. Calculate loss:loss = loss_fn(y_pred, y_train)3. Optimizer zero grad:optimizer.zero_grad()4. Backpropagation:loss.backward()5. Optimizer step:optimizer.step().
- Forward pass:
What is the purpose of
model.eval()andtorch.inference_mode()during evaluation?model.eval()sets the model to evaluation mode (disables dropout/batch norm).torch.inference_mode()disables gradient tracking for faster computation.What are the top three common errors in PyTorch/deep learning?
- Wrong data type (dtype) 2. Wrong shape (tensor dimensions mismatch) 3. Wrong device (tensors on CPU but model on GPU or vice-versa).
What is the rule for matrix multiplication of two tensors?
Inner dimensions must match:
(a, b)@(b, c)works, resulting in(a, c). If shapes don't match, try transposing one tensor.How do you save and load a PyTorch model's learned parameters?
Save:
torch.save(model.state_dict(), 'model.pth'). Load: instantiate a new model, thenmodel.load_state_dict(torch.load('model.pth')), then move to device.What are the three types of classification problems?
Binary classification (two classes), multi-class classification (more than two, one label per sample), and multi-label classification (multiple labels per sample).
What is the output activation for binary vs. multi-class classification?
Binary:
torch.sigmoid()outputs a probability between 0 and 1. Multi-class:torch.softmax(dim=1)outputs probabilities summing to 1 over classes.What loss functions are recommended for binary and multi-class classification?
Binary:
nn.BCEWithLogitsLoss()(more numerically stable). Multi-class:nn.CrossEntropyLoss().Describe the 'logits pipeline' from model output to predicted label.
- Logits (raw outputs) → 2. Prediction probabilities via activation (sigmoid/softmax) → 3. Prediction labels:
torch.round()for binary ortorch.argmax(dim=1)for multi-class.
- Logits (raw outputs) → 2. Prediction probabilities via activation (sigmoid/softmax) → 3. Prediction labels:
Why is non-linearity essential in neural networks?
Without non-linear activation functions, a stack of linear layers can only model linear relationships (straight lines). Non-linearity allows the network to learn complex patterns, e.g., separating circular data.
What is the common architecture of a classification neural network?
Input layer (matching number of features) → Hidden layers (with activation functions like ReLU) → Output layer (matching number of classes) → Output activation (sigmoid or softmax).
What are the main Python libraries for computer vision in PyTorch?
torchvision(datasets, models, transforms) and core PyTorch utilities:torch.utils.data.DatasetandDataLoader.What is the shape convention for image tensors in PyTorch?
[batch_size, color_channels, height, width]. For grayscale,color_channels=1; for RGB,color_channels=3.What is the purpose of using DataLoaders (batching) in training?
- Computationally efficient (process multiple samples at once) 2. More gradient updates per epoch (faster learning) compared to single-sample processing.
What are the key hyperparameters of
nn.Conv2d?in_channels,out_channels(number of filters),kernel_size,stride,padding.What does
nn.MaxPool2ddo?It compresses the image by taking the maximum value from a small window (e.g., 2x2), reducing height and width (downsampling). It is a non-learnable layer.
Describe the TinyVGG CNN architecture.
Input → Conv Block 1 (Conv2d → ReLU → Conv2d → ReLU → MaxPool2d) → Conv Block 2 (Conv2d → ReLU → Conv2d → ReLU → MaxPool2d) → Classifier (Flatten → Linear to output classes).
What three things must be checked when using custom image data in PyTorch?
- Data type (
float32) 2. Shape (matches model's expected input dimensions) 3. Device (tensors on same device as model).
- Data type (

Ask anything
We've read this whole study set, so questions about it get the best answers.