Deep Learning with PyTorch
- 131Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
Which description best captures the structure of a basic deep learning model?
Which description best captures the structure of a basic deep learning model?
131 questions
- 1
Which description best captures the structure of a basic deep learning model?
- A
Hidden layers provide the training labels, while input layers produce predictions.
- B
Inputs connect directly to outputs, and every network must contain exactly one hidden layer.
- C
Inputs pass through hidden layers to produce outputs, and a network may have one or many hidden layers.
- D
Outputs pass through the input layer before being processed by hidden layers.
Correct answer
CInputs pass through hidden layers to produce outputs, and a network may have one or many hidden layers.
Explanation
A neural network consists of input, hidden, and output layers. Networks can contain different numbers of hidden layers, including none.
- A
- 2
Why are these models called neural networks?
- A
Their original inspiration was interconnected cells, called neurons, in the human brain.
- B
They require neurons from biological tissue to calculate model predictions.
- C
They process only data collected from human brains and nervous systems.
- D
Their layers reproduce the brain's biological structure exactly.
Correct answer
ATheir original inspiration was interconnected cells, called neurons, in the human brain.
Explanation
The original intuition was to create models inspired by how the brain learns through interconnected neurons; the models do not reproduce the brain exactly.
- A
- 3
Compared with many other machine learning models, what is a common data requirement of deep learning?
- A
It often requires at least hundreds of thousands of data points to derive patterns.
- B
It requires exactly the same amount of data as every other machine learning model.
- C
It can learn patterns without data if its network has enough hidden layers.
- D
It generally requires only a few dozen examples because layers create new data.
Correct answer
AIt often requires at least hundreds of thousands of data points to derive patterns.
Explanation
Layered deep learning models commonly need substantially more data than other machine learning approaches, often at least hundreds of thousands of data points.
- A
- 4
Which statement about PyTorch is supported by the material?
- A
It was developed by an academic research lab and is maintained only by Facebook.
- B
It was developed as part of NumPy and later became a general-purpose Python interpreter.
- C
It was developed by Meta AI in Facebook's AI research lab and later moved under the Linux Foundation.
- D
It was developed by the Linux Foundation and later moved into Meta AI's research lab.
Correct answer
CIt was developed by Meta AI in Facebook's AI research lab and later moved under the Linux Foundation.
Explanation
PyTorch was originally developed by Meta AI as part of Facebook's AI research lab and later moved under the Linux Foundation.
- A
- 5
What is the fundamental data structure used by PyTorch?
- A
A Python class, which automatically converts all data into predictions.
- B
A tensor, which is similar to an array or matrix and supports mathematical operations.
- C
A label, which holds the input features and the model's hidden states.
- D
A dataframe, which stores every model layer and its learned parameters.
Correct answer
BA tensor, which is similar to an array or matrix and supports mathematical operations.
Explanation
Tensors are PyTorch's fundamental data structure. They can be created from Python lists or NumPy arrays and support mathematical operations.
- A
- 6
What does checking a tensor's shape and data type help a developer verify?
- A
That the model will produce the correct predictions for every input.
- B
That the tensor's dimensions and format are compatible with the model and task.
- C
That the model has already learned accurate weights from the tensor.
- D
That the tensor contains no missing values and needs no further inspection.
Correct answer
BThat the tensor's dimensions and format are compatible with the model and task.
Explanation
Inspecting a tensor's shape and data type helps ensure it aligns with the model and task, and can assist with debugging.
- A
- 7
When can two PyTorch tensors be added or subtracted according to the material?
- A
When one tensor has fewer dimensions than the other.
- B
When their total numbers of elements are equal, regardless of shape.
- C
When their data types are the same, even if their shapes differ.
- D
When their shapes are the same, so their dimensions align exactly.
Correct answer
DWhen their shapes are the same, so their dimensions align exactly.
Explanation
The described addition and subtraction operations require compatible shapes; in this material, compatibility means the same shape.
- A
- 8
How is each value in a matrix product formed?
- A
By multiplying matching positions in both matrices and retaining each product separately.
- B
By adding a row of the first matrix to a column of the second and averaging the values.
- C
By multiplying a row of the first matrix by a column of the second and summing the products.
- D
By summing the first matrix's rows and copying those totals into the second matrix.
Correct answer
CBy multiplying a row of the first matrix by a column of the second and summing the products.
Explanation
Each value in a matrix product is the sum of the element-wise products of a row from the first matrix and a column from the second.
- A
- 9
What do the input and output layer dimensions represent when designing a network for classification?
- A
The input dimension is the number of classes, and the output dimension is the number of features.
- B
The input dimension is the number of features, and the output dimension is the number of classes.
- C
Both dimensions are determined by the number of hidden layers in the network.
- D
The input dimension is the number of samples, and the output dimension is the number of features.
Correct answer
BThe input dimension is the number of features, and the output dimension is the number of classes.
Explanation
The input layer has one neuron per dataset feature, while the output layer has one neuron per class being predicted.
- A
- 10
A linear layer receives an input with three features and should produce two output values. Which dimensions should be specified?
- A
Three input features and two output features.
- B
Three input features and three output features.
- C
Two input features and three output features.
- D
Two input features and two output features.
Correct answer
AThree input features and two output features.
Explanation
The layer's input dimension must match the input tensor's three features, and its output dimension should be two.
- A
- 11
What roles do weights and biases play in a linear layer?
- A
Weights encode the true labels, while a bias measures prediction accuracy.
- B
Weights set the number of classes, while a bias determines the input tensor's shape.
- C
Weights control the learning rate, while a bias determines the batch size.
- D
Weights reflect feature importance, while a bias adds a baseline term independent of the weights.
Correct answer
DWeights reflect feature importance, while a bias adds a baseline term independent of the weights.
Explanation
Weights determine how input features contribute to a neuron's output. The bias is an additional term that can provide a baseline output.
- A
- 12
What is the main constraint when stacking linear layers in sequence?
- A
Each layer's input dimension must match the preceding layer's output dimension.
- B
Each layer must have the same input and output dimension.
- C
Every layer must have fewer neurons than the layer before it.
- D
The final layer must have more outputs than the first layer has inputs.
Correct answer
AEach layer's input dimension must match the preceding layer's output dimension.
Explanation
The dimensions must connect: each layer must accept the number of values produced by the previous layer.
- A
- 13
A fully connected layer receives eight values and has four neurons. How many learnable parameters does it have?
- A
Twelve: eight input weights and four output biases in total.
- B
Forty: eight weights and two biases for each of four neurons.
- C
Thirty-six: eight weights and one bias for each of four neurons.
- D
Thirty-two: eight weights for each of four neurons and no biases.
Correct answer
CThirty-six: eight weights and one bias for each of four neurons.
Explanation
Each of the four neurons has eight weights and one bias, so the layer has four times nine, or thirty-six, parameters.
- A
- 14
A network has a first layer with four neurons, each with eight weights and one bias, and a second layer with two neurons, each with four weights and one bias. What is its total parameter count?
- A
Forty parameters.
- B
Forty-six parameters.
- C
Fifty parameters.
- D
Thirty-six parameters.
Correct answer
BForty-six parameters.
Explanation
The first layer has four times nine, or thirty-six, parameters. The second has two times five, or ten. Together they have forty-six.
- A
- 15
Why can adding layers increase both a model's usefulness and its training cost?
- A
More parameters eliminate training time by allowing the model to skip optimization.
- B
More layers reduce the number of parameters but require more data transformations at evaluation.
- C
More parameters can represent more complex patterns but may take longer to train and increase overfitting risk.
- D
More layers guarantee better generalization but prevent the model from fitting complex datasets.
Correct answer
CMore parameters can represent more complex patterns but may take longer to train and increase overfitting risk.
Explanation
Greater model capacity can help a network handle complex datasets, but additional parameters can increase training time and overfitting risk.
- A
- 16
What is the purpose of a nonlinear activation between linear layers?
- A
It converts all model parameters into probabilities before training begins.
- B
It ensures every hidden layer has the same number of neurons as the output layer.
- C
It enables the network to learn complex interactions beyond purely linear relationships.
- D
It removes the need for weights and biases in the linear layers.
Correct answer
CIt enables the network to learn complex interactions beyond purely linear relationships.
Explanation
Nonlinear activations let networks learn more complex relationships than a stack of linear operations alone.
- A
- 17
What is the pre-activation output of a network?
- A
The gradient of the loss before it is used to update the parameters.
- B
The ground-truth value before it is converted into a tensor.
- C
The model's final class label after a probability threshold has been applied.
- D
The output of the last linear layer before it is passed through an activation function.
Correct answer
DThe output of the last linear layer before it is passed through an activation function.
Explanation
The pre-activation output is the output of the final linear layer before an activation function transforms it.
- A
- 18
Why is sigmoid commonly used for binary classification?
- A
It converts a class label into a vector of zeros and ones for any number of classes.
- B
It maps model outputs to any real number, allowing direct prediction of continuous targets.
- C
It transforms a single model output into a value between zero and one that can represent a probability.
- D
It transforms any number of outputs into class probabilities that always sum to one.
Correct answer
CIt transforms a single model output into a value between zero and one that can represent a probability.
Explanation
Sigmoid maps an input to the range from zero to one, making its output interpretable as a binary-class probability.
- A
- 19
A binary classifier produces a sigmoid output of 0.7. Using the described threshold rule, what label should it predict?
- A
Class one, because the probability is greater than 0.5.
- B
Class one, because every sigmoid output represents the positive class.
- C
Class zero, because every probability below one is negative.
- D
Class zero, because the probability is greater than 0.5.
Correct answer
AClass one, because the probability is greater than 0.5.
Explanation
With the stated threshold, probabilities greater than 0.5 are assigned to class one; values below 0.5 are assigned to class zero.
- A
- 20
What does a softmax output represent in a multiclass classification task?
- A
A single probability that identifies whether the input belongs to any class.
- B
A vector of unbounded scores whose largest value is always negative.
- C
A probability distribution whose values are between zero and one and sum to one.
- D
A set of independent probabilities that may sum to any value.
Correct answer
CA probability distribution whose values are between zero and one and sum to one.
Explanation
Softmax produces one probability per class; each value lies between zero and one, and the values sum to one.
- A
- 21
A softmax classifier outputs probabilities for three classes. How is its predicted class selected?
- A
Choose the first class whose probability is greater than zero.
- B
Choose the class with the highest probability.
- C
Choose the class whose probability is closest to 0.5.
- D
Choose the class with the lowest probability.
Correct answer
BChoose the class with the highest probability.
Explanation
For multiclass prediction, the assigned label is the class with the largest softmax probability.
- A
- 22
Why is a sigmoid activation generally unsuitable for hidden layers in a deep network?
- A
It makes all input features have identical weights.
- B
For very large or small inputs, its gradients become very small and can cause vanishing gradients.
- C
Its outputs are unbounded, so hidden-layer values grow without limit.
- D
It requires every hidden layer to have exactly one neuron.
Correct answer
BFor very large or small inputs, its gradients become very small and can cause vanishing gradients.
Explanation
Sigmoid can saturate at large positive or negative inputs, producing very small gradients that hinder parameter updates during backpropagation.
- A
- 23
How does ReLU transform its input?
- A
It returns zero for positive values and the input for negative values.
- B
It maps every input to a probability distribution over classes.
- C
It returns the input for positive values and zero for negative values.
- D
It maps every input into the range between zero and one.
Correct answer
CIt returns the input for positive values and zero for negative values.
Explanation
ReLU returns the maximum of its input and zero: positive inputs pass through, while negative inputs become zero.
- A
- 24
How does leaky ReLU differ from standard ReLU for negative inputs?
- A
It maps negative inputs to one and positive inputs to zero.
- B
It sets negative inputs to zero but increases the gradient for positive inputs.
- C
It multiplies negative inputs by a small coefficient, leaving a nonzero gradient.
- D
It converts negative inputs to positive values by taking their absolute value.
Correct answer
CIt multiplies negative inputs by a small coefficient, leaving a nonzero gradient.
Explanation
Leaky ReLU applies a small negative-slope coefficient to negative inputs, so their gradients remain nonzero.
- A
- 25
When is cross-entropy loss appropriate, and what does it compare?
- A
For regression, it compares model weights with the optimizer's learning rate.
- B
For regression, it compares continuous predictions with squared target values.
- C
For classification, it compares model scores with the encoded ground-truth class.
- D
For classification, it compares only the model's final predicted label with the input features.
Correct answer
CFor classification, it compares model scores with the encoded ground-truth class.
Explanation
Cross-entropy is commonly used for classification. In the described workflow, it receives the model's scores and the one-hot encoded target.
- A
- 26
With three classes, what one-hot vector represents class one when class indices are zero-based?
- A
A vector with one in the second position and zero elsewhere.
- B
A vector with one in the third position and zero elsewhere.
- C
A vector with equal values in all three positions.
- D
A vector with one in the first position and zero elsewhere.
Correct answer
AA vector with one in the second position and zero elsewhere.
Explanation
One-hot encoding places a one at the position corresponding to the class index. Class one therefore has its one in the second position.
- A
- 27
Which output-layer design is appropriate for the regression example described?
- A
A linear layer with one output and no final sigmoid or softmax activation.
- B
A sigmoid layer with one output so every prediction is between zero and one.
- C
A softmax layer with one output so each prediction is a class probability.
- D
A softmax layer with one output for each training sample.
Correct answer
AA linear layer with one output and no final sigmoid or softmax activation.
Explanation
The regression model predicts continuous values, so the example uses a one-output linear layer without a final classification activation.
- A
- 28
What does mean squared error measure?
- A
The mean of the squared differences between predictions and ground-truth values.
- B
The largest difference between a prediction and a ground-truth value.
- C
The fraction of predictions that match their one-hot encoded labels.
- D
The mean of the absolute differences between predictions and class indices.
Correct answer
AThe mean of the squared differences between predictions and ground-truth values.
Explanation
MSE averages the squared errors between predictions and targets. Squaring prevents positive and negative errors from canceling and penalizes larger errors more.
- A
- 29
What does a loss function provide during model training?
- A
A guarantee that the model will generalize to unseen data.
- B
A fixed count of how many features are in each training sample.
- C
A numerical measure of prediction error that training aims to minimize.
- D
A class label that replaces the model's predicted output.
Correct answer
CA numerical measure of prediction error that training aims to minimize.
Explanation
A loss function compares predictions with ground truth and produces a numerical value indicating how poorly the model predicted; training aims to reduce it.
- A
- 30
What is the purpose of a forward pass?
- A
To convert predicted class indices into one-hot encoded targets.
- B
To pass inputs through the model's layers and produce predictions using its current parameters.
- C
To compute parameter gradients and update the weights using the optimizer.
- D
To split a dataset into training, validation, and test subsets.
Correct answer
BTo pass inputs through the model's layers and produce predictions using its current parameters.
Explanation
During a forward pass, input data flows through the network's layers until the model produces its output.
- A
- 31
Why is a model's output before training updates not necessarily meaningful?
- A
Its weights and biases may still be randomly initialized and need to be tuned through training.
- B
The output becomes meaningful only after every input is converted to a one-hot vector.
- C
A forward pass cannot produce predictions until the test set is evaluated.
- D
Random initialization means the model has already minimized the loss.
Correct answer
AIts weights and biases may still be randomly initialized and need to be tuned through training.
Explanation
A model initially has randomly initialized weights and biases. Training updates these parameters so the predictions can become useful.
- A
- 32
In a classification dataset, why might the animal name column be excluded from the input features?
- A
The name column contains the target labels rather than the animal's name.
- B
Names cannot be stored in a CSV file or loaded into a dataframe.
- C
The name itself does not determine the animal's classification, unlike its relevant characteristics.
- D
Names must be used as the output layer's neuron count.
Correct answer
CThe name itself does not determine the animal's classification, unlike its relevant characteristics.
Explanation
The example uses characteristics such as hair, feathers, and legs as features and omits the animal name because it does not determine the class.
- A
- 33
What is the role of a PyTorch TensorDataset?
- A
It converts model outputs into loss values without requiring targets.
- B
It randomly initializes the model's weights and biases.
- C
It organizes feature and target tensors so samples can be accessed together.
- D
It calculates class accuracy for every training batch.
Correct answer
CIt organizes feature and target tensors so samples can be accessed together.
Explanation
TensorDataset stores tensors such as features and labels together, allowing an individual sample to return its input and corresponding target.
- A
- 34
What does a DataLoader's batch size determine?
- A
How many classes the model is permitted to predict.
- B
How many epochs the optimizer runs before updating parameters.
- C
How many samples are included in each iteration over the data.
- D
How many features are stored in each individual sample.
Correct answer
CHow many samples are included in each iteration over the data.
Explanation
Batch size is the number of samples the DataLoader provides in an iteration.
- A
- 35
Why shuffle training samples between epochs?
- A
Ensuring the same samples are always grouped together can prevent overfitting.
- B
Changing their labels can help balance the classes automatically.
- C
Reducing the number of samples can make each epoch complete faster.
- D
Randomizing their order can help improve the model's generalization.
Correct answer
DRandomizing their order can help improve the model's generalization.
Explanation
Shuffling randomizes sample order at each epoch and can help the model generalize rather than depend on a fixed ordering.
- A
- 36
What is one epoch?
- A
One prediction from the output layer.
- B
One complete pass through the training data.
- C
One update to a single model parameter.
- D
One batch from the validation data.
Correct answer
BOne complete pass through the training data.
Explanation
An epoch is a full pass through the training dataset or its DataLoader.
- A
- 37
A dataset has five samples and a batch size of two. If the final partial batch is retained, how many samples are in the last batch?
- A
Two samples.
- B
Five samples.
- C
One sample.
- D
Three samples.
Correct answer
COne sample.
Explanation
Two batches of two account for four samples, leaving one sample for the final batch.
- A
- 38
Why must predictions and targets both be floating-point tensors in the described MSE workflow?
- A
The DataLoader can batch data only when all tensors contain floating-point values.
- B
The regression loss and model parameters use floating-point values.
- C
MSE accepts only integer labels, so both tensors must be converted to floats.
- D
Floating-point tensors automatically encode each target as a class.
Correct answer
BThe regression loss and model parameters use floating-point values.
Explanation
The regression example casts features and targets to floats, matching the floating-point data type used by the model parameters and MSE workflow.
- A
- 39
Why does a training loop clear gradients before processing a new batch?
- A
Clearing gradients reinitializes the model's weights before every forward pass.
- B
Clearing gradients changes the target labels into the correct data type.
- C
Optimizers retain gradients by default, so clearing them prevents previous gradients from carrying over.
- D
Gradients can be computed only once per epoch, so they must be deleted between batches.
Correct answer
COptimizers retain gradients by default, so clearing them prevents previous gradients from carrying over.
Explanation
Gradients accumulate unless cleared. The training loop uses the optimizer's zero-grad operation to start each batch with clean gradients.
- A
- 40
What does backpropagation calculate?
- A
The input dimensions required by each linear layer.
- B
Gradients of the loss with respect to model parameters.
- C
The model's final accuracy without using target labels.
- D
The number of samples in each class of the dataset.
Correct answer
BGradients of the loss with respect to model parameters.
Explanation
Backpropagation computes loss gradients for model parameters, which can then guide updates to weights and biases.
- A
- 41
What does the optimizer do during a training step?
- A
It selects which output class is the ground truth.
- B
It calculates the number of hidden layers required by the dataset.
- C
It converts the training data into one-hot encoded labels.
- D
It uses parameter gradients to update the model's parameters.
Correct answer
DIt uses parameter gradients to update the model's parameters.
Explanation
The optimizer applies parameter updates based on the gradients computed from the loss.
- A
- 42
Why should a parameter with a positive loss gradient generally be decreased during gradient descent?
- A
Decreasing the parameter guarantees the loss reaches its global minimum immediately.
- B
Moving against the gradient direction tends to reduce the loss.
- C
The optimizer can update parameters only when their gradients are positive.
- D
Positive gradients indicate that the parameter has no effect on the loss.
Correct answer
BMoving against the gradient direction tends to reduce the loss.
Explanation
Gradient descent updates parameters in the direction opposite the loss gradient, so a positive gradient calls for a decrease in the parameter.
- A
- 43
How does the learning rate affect stochastic gradient descent?
- A
It controls whether the model uses sigmoid or softmax.
- B
It determines the number of output classes in the final layer.
- C
It determines how many samples are included in a batch.
- D
It controls the step size used for parameter updates.
Correct answer
DIt controls the step size used for parameter updates.
Explanation
The learning rate is a tunable hyperparameter that controls the size of optimizer updates.
- A
- 44
What is a likely effect of setting the learning rate too low?
- A
The optimizer repeatedly overshoots the minimum with large steps.
- B
Training progresses slowly because the optimizer takes small steps.
- C
The model automatically becomes more complex and overfits.
- D
The loss becomes independent of the model's parameters.
Correct answer
BTraining progresses slowly because the optimizer takes small steps.
Explanation
A very small learning rate makes updates small, so the optimizer may take much longer to approach a minimum.
- A
- 45
What is a likely effect of setting the learning rate too high?
- A
The optimizer becomes unable to calculate gradients.
- B
The optimizer takes smaller steps near the minimum than intended.
- C
The optimizer can overshoot and bounce around rather than settle at a minimum.
- D
The model's output layer automatically gains extra neurons.
Correct answer
CThe optimizer can overshoot and bounce around rather than settle at a minimum.
Explanation
An excessively high learning rate can cause updates to jump across the minimum, preventing convergence.
- A
- 46
What does momentum contribute to an optimizer?
- A
It forces the learning rate to be zero whenever a gradient is small.
- B
It shuffles samples and changes their order between epochs.
- C
It replaces gradients with the model's accuracy score.
- D
It uses inertia from past updates to help movement continue smoothly and pass local dips.
Correct answer
DIt uses inertia from past updates to help movement continue smoothly and pass local dips.
Explanation
Momentum incorporates the effect of previous steps, helping the optimizer move smoothly and sometimes overcome local minima.
- A
- 47
Why can momentum help on a non-convex loss surface?
- A
It removes the need to compute gradients during training.
- B
It can keep updates substantial after large previous steps, helping the optimizer move past a local minimum.
- C
It guarantees that every model parameter decreases at every step.
- D
It makes every local minimum equal to the global minimum.
Correct answer
BIt can keep updates substantial after large previous steps, helping the optimizer move past a local minimum.
Explanation
Momentum can preserve a large step even when the current gradient is small, helping the optimizer pass local dips that might trap it otherwise.
- A
- 48
How does Adam combine ideas from other optimizers?
- A
It combines adaptive learning-rate behavior associated with RMSprop and momentum from past gradients.
- B
It combines batch shuffling with a fixed learning rate for every update.
- C
It combines softmax predictions with cross-entropy targets.
- D
It combines one-hot encoding with the parameter count of a linear layer.
Correct answer
AIt combines adaptive learning-rate behavior associated with RMSprop and momentum from past gradients.
Explanation
Adam combines RMSprop-like adaptation with a momentum concept that averages past gradients, giving more weight to recent gradients.
- A
- 49
What kind of data is Adagrad especially suited to, according to the material?
- A
Sparse data with features that are observed infrequently.
- B
Dense data in which every feature appears in every sample.
- C
Image data that has already been converted to class indices.
- D
Sequential data that must be split randomly across time.
Correct answer
ASparse data with features that are observed infrequently.
Explanation
Adagrad decreases learning rates for parameters that are updated infrequently, making it well-suited to sparse data.
- A
- 50
Which optimizer is presented as a common default choice for general training?
- A
Adagrad, because it never changes learning rates.
- B
Adam, because it is versatile and widely used.
- C
Plain SGD, because it always outperforms adaptive methods.
- D
RMSprop, because it does not use gradient information.
Correct answer
BAdam, because it is versatile and widely used.
Explanation
Adam is described as a versatile, widely used optimizer and a common go-to choice.
- A
- 51
What is the purpose of using a validation set?
- A
To adjust model weights as the only source of training data.
- B
To provide the final unbiased performance score after all tuning.
- C
To replace the training set when calculating gradients.
- D
To tune hyperparameters such as learning rate and momentum.
Correct answer
DTo tune hyperparameters such as learning rate and momentum.
Explanation
The training set adjusts model parameters, the validation set supports hyperparameter tuning, and the test set evaluates final performance.
- A
- 52
What does the test set primarily measure?
- A
The best learning rate before training begins.
- B
The model's final performance after training and model selection.
- C
The model's ability to memorize the training labels.
- D
The model's parameter updates during each training batch.
Correct answer
BThe model's final performance after training and model selection.
Explanation
The test set is used to evaluate the model's final performance, while training and validation serve different roles.
- A
- 53
How is mean training loss for an epoch calculated in the described procedure?
- A
Sum the batch losses and divide by the number of model parameters.
- B
Average the training accuracy and multiply it by the number of batches.
- C
Sum the batch losses and divide by the number of training batches.
- D
Subtract the validation loss from the total number of training samples.
Correct answer
CSum the batch losses and divide by the number of training batches.
Explanation
The procedure adds each batch's loss and divides the total by the number of batches to obtain mean training loss.
- A
- 54
Why use evaluation mode and disable gradient calculations during validation?
- A
Evaluation mode handles layers that behave differently, and gradients are unnecessary when weights are not being updated.
- B
Evaluation mode recalculates training gradients, while disabling gradients updates weights more accurately.
- C
Both steps convert validation labels into training labels.
- D
They make the validation set part of the optimizer's parameter list.
Correct answer
AEvaluation mode handles layers that behave differently, and gradients are unnecessary when weights are not being updated.
Explanation
Evaluation mode sets the model's layers to evaluation behavior, and disabling gradients avoids unnecessary calculations because validation does not update weights.
- A
- 55
Which pattern is evidence of overfitting?
- A
Training and validation accuracy both remain at chance level.
- B
Validation loss falls while training loss rises steadily.
- C
Training loss continues to fall while validation loss begins to rise.
- D
Both training and validation loss fall at the same rate.
Correct answer
CTraining loss continues to fall while validation loss begins to rise.
Explanation
When training loss decreases but validation loss rises, the model may be fitting the training data too closely and generalizing poorly.
- A
- 56
In multiclass classification, how can a vector of class probabilities be turned into predicted class indices?
- A
Use argmax along the class dimension to select the highest-probability class.
- B
Apply one-hot encoding to the input features.
- C
Use the mean along the class dimension and round the result.
- D
Use the minimum probability as the predicted class index.
Correct answer
AUse argmax along the class dimension to select the highest-probability class.
Explanation
Argmax selects the class with the highest predicted probability and returns its index.
- A
- 57
What does precision measure for a class?
- A
The fraction of all examples of that class that were correctly found.
- B
The fraction of all examples assigned to any class correctly.
- C
The fraction of predictions for that class that are correct.
- D
The number of false negatives divided by the number of classes.
Correct answer
CThe fraction of predictions for that class that are correct.
Explanation
Precision measures how many predicted positives are correct. Recall measures how many actual positives were correctly identified.
- A
- 58
What does recall measure for a class?
- A
The fraction of predictions for that class that are correct.
- B
The fraction of all predictions that belong to the largest class.
- C
The fraction of all actual examples of that class that were correctly predicted.
- D
The number of correct predictions divided by the number of model parameters.
Correct answer
CThe fraction of all actual examples of that class that were correctly predicted.
Explanation
Recall measures the fraction of actual positive examples that the model correctly identifies.
- A
- 59
How does macro averaging aggregate per-class precision or recall?
- A
It reports only the score for the largest class.
- B
It pools all class counts first, so larger classes dominate the result.
- C
It weights each class's score by its number of samples.
- D
It computes the metric for each class and takes their unweighted mean.
Correct answer
DIt computes the metric for each class and takes their unweighted mean.
Explanation
Macro averaging gives every class equal weight by averaging the independently calculated class scores.
- A
- 60
How does weighted averaging differ from macro averaging?
- A
It weights each class's metric according to the number of samples in that class.
- B
It gives every class equal weight regardless of its size.
- C
It reports the minimum score among all classes.
- D
It computes one global metric without calculating class-specific scores.
Correct answer
AIt weights each class's metric according to the number of samples in that class.
Explanation
Weighted averaging uses class sizes as weights, so classes with more samples have greater influence on the final result.
- A
- 61
Which averaging approach calculates metrics globally from the total true positives, false positives, and false negatives?
- A
Per-class averaging.
- B
Weighted averaging.
- C
Micro averaging.
- D
Macro averaging.
Correct answer
CMicro averaging.
Explanation
Micro averaging aggregates the counts across all classes before computing precision or recall.
- A
- 62
When might macro averaging be especially useful?
- A
When performance on smaller classes matters as much as performance on larger classes.
- B
When errors in larger classes should dominate the overall score.
- C
When only the most common class is relevant.
- D
When the goal is to pool all class counts into one global metric.
Correct answer
AWhen performance on smaller classes matters as much as performance on larger classes.
Explanation
Macro averaging weights classes equally, making it useful when performance on smaller classes should not be overshadowed by larger ones.
- A
- 63
Which condition can contribute to overfitting?
- A
A linear output layer used for a continuous regression target.
- B
A validation set, a test set, or a shuffled training loader.
- C
A large dataset, a small model, or low weight values.
- D
A small dataset, excessive model capacity, or large weights.
Correct answer
DA small dataset, excessive model capacity, or large weights.
Explanation
The material identifies small datasets, models with too much capacity, and large weights as factors that can promote overfitting.
- A
- 64
What does dropout do during training?
- A
It adds extra neurons whenever the model's loss increases.
- B
It permanently removes the same neurons from the model before every training run.
- C
It randomly deactivates a fraction of neurons so the model relies less on particular features.
- D
It randomly changes target labels to increase class diversity.
Correct answer
CIt randomly deactivates a fraction of neurons so the model relies less on particular features.
Explanation
Dropout is a regularization technique that randomly sets some neuron outputs to zero during training.
- A
- 65
How does dropout behave during evaluation?
- A
It deactivates the same fraction of neurons as during training.
- B
It removes the output layer and uses the hidden layer predictions.
- C
It replaces the model's weights with random values.
- D
It is disabled so all neurons are active for stable predictions.
Correct answer
DIt is disabled so all neurons are active for stable predictions.
Explanation
Dropout is used during training but disabled during evaluation, when all neurons are active.
- A
- 66
How does weight decay help reduce overfitting?
- A
It penalizes large weights, encouraging parameters to remain smaller.
- B
It prevents the model from calculating gradients.
- C
It increases the number of training samples by repeating each batch.
- D
It increases model capacity by adding additional layers.
Correct answer
AIt penalizes large weights, encouraging parameters to remain smaller.
Explanation
Weight decay adds a regularization penalty that encourages smaller weights and can reduce excessive weight growth.
- A
- 67
Why should data augmentation be chosen with the task and labels in mind?
- A
Every transformation necessarily makes the label more accurate.
- B
Transformations never affect image meaning, so their choice is irrelevant.
- C
Some transformations can change what an example depicts while its original label remains unchanged.
- D
Augmentation is useful only when the original dataset has no labels.
Correct answer
CSome transformations can change what an example depicts while its original label remains unchanged.
Explanation
A transformation can make an image appear to belong to a different class, such as flipping a handwritten character, while leaving its label unchanged.
- A
- 68
What information does a grayscale pixel value represent in the described image format?
- A
A shade from black to white, represented by an integer from zero to 255.
- B
The pixel's position in the image, represented by an integer from one to 255.
- C
A class probability represented by a number from zero to one.
- D
Three separate color-channel intensities, each stored as a floating-point value.
Correct answer
AA shade from black to white, represented by an integer from zero to 255.
Explanation
A grayscale pixel records a shade between black and white; the described representation uses integers from zero to 255.
- A
- 69
How is a typical color image pixel represented?
- A
By one grayscale value and two model parameters.
- B
By its height, width, and batch position.
- C
By intensities for red, green, and blue color channels.
- D
By a single class index and two label indicators.
Correct answer
CBy intensities for red, green, and blue color channels.
Explanation
A color pixel is typically described by three values for the red, green, and blue channels.
- A
- 70
Why is an image dataset arranged into category-specific directories suitable for
ImageFolder?- A
The directory structure automatically converts image pixels into model weights.
- B
The directory structure lets the dataset associate image files with their category labels.
- C
The directory structure prevents images from being resized or transformed.
- D
The directory structure ensures every category contains the same number of images.
Correct answer
BThe directory structure lets the dataset associate image files with their category labels.
Explanation
With images stored in directories representing categories,
ImageFoldercan construct a dataset with category labels. - A
- 71
A loaded color image has shape one by three by 128 by 128. What do those dimensions represent?
- A
Color channels, batch size, width, and height.
- B
Height, width, color channels, and batch size.
- C
Batch size, color channels, height, and width.
- D
Batch size, height, width, and number of categories.
Correct answer
CBatch size, color channels, height, and width.
Explanation
The described tensor uses batch-first image dimensions: batch size, channels, height, and width.
- A
- 72
Why might image dimensions be permuted before displaying a color image?
- A
The permutation converts a color image into a grayscale image.
- B
The permutation removes the image's class label from the tensor.
- C
Display tools commonly expect height and width before the color-channel dimension.
- D
Display tools require color channels to be stored as the batch dimension.
Correct answer
CDisplay tools commonly expect height and width before the color-channel dimension.
Explanation
The model-style image tensor places channels before height and width, while image display commonly expects the channel dimension last.
- A
- 73
What is data augmentation for images?
- A
Duplicating the model's output layer to increase the number of predictions.
- B
Applying transformations such as flips or rotations to create varied training examples.
- C
Removing all images whose labels are difficult for the model.
- D
Replacing each image with a randomly generated class label.
Correct answer
BApplying transformations such as flips or rotations to create varied training examples.
Explanation
Data augmentation creates varied versions of training images, increasing training-set diversity and potentially improving robustness.
- A
- 74
Why can feeding a large image directly into a dense layer be inefficient?
- A
It forces every image pixel to have the same color value.
- B
It automatically converts the image into a sequence of class labels.
- C
It cannot be used with floating-point inputs or gradient descent.
- D
It can create an enormous number of parameters and may fail to capture spatial patterns across image locations.
Correct answer
DIt can create an enormous number of parameters and may fail to capture spatial patterns across image locations.
Explanation
Flattening large images for dense layers can produce very large parameter counts, and dense connections do not naturally preserve spatial relationships.
- A
- 75
How does a convolutional filter produce values in a feature map?
- A
It selects the most common class label in each region of the image.
- B
It sorts all pixels by brightness and stores the median value.
- C
It connects each input pixel to every output class independently.
- D
It slides across input patches and computes a dot product at each position.
Correct answer
DIt slides across input patches and computes a dot product at each position.
Explanation
At each location, the filter and input patch are multiplied element by element and summed to produce a feature-map value.
- A
- 76
What is one purpose of zero padding in a convolutional layer?
- A
It can help preserve spatial dimensions and give border pixels more equal treatment.
- B
It converts every convolution into a fully connected operation.
- C
It ensures that every filter has only one learnable parameter.
- D
It adds new image classes to the model's output.
Correct answer
AIt can help preserve spatial dimensions and give border pixels more equal treatment.
Explanation
Padding adds zeros around an input, helping maintain spatial dimensions and reducing the disadvantage border pixels would otherwise face.
- A
- 77
What does a two-by-two max-pooling window do at each position?
- A
It passes forward the smallest value in that window.
- B
It sums the window values and uses the sum as a class score.
- C
It passes forward the average of all values in that window.
- D
It passes forward the largest value in that window.
Correct answer
DIt passes forward the largest value in that window.
Explanation
Max pooling selects the maximum value from each window. With the described non-overlapping two-by-two window, it halves height and width.
- A
- 78
What is the usual role of the feature extractor and classifier in the described convolutional network?
- A
The classifier extracts pixel values, while the feature extractor assigns the final class.
- B
Convolutional, activation, and pooling layers extract image features; a flattened representation is passed to a classifier.
- C
The feature extractor stores the labels, while the classifier resizes the images.
- D
The classifier performs data augmentation, while the feature extractor calculates the loss.
Correct answer
BConvolutional, activation, and pooling layers extract image features; a flattened representation is passed to a classifier.
Explanation
The convolutional feature extractor transforms the image into useful features; the classifier maps those features to class outputs.
- A
- 79
Why should test images generally not receive random training augmentations during evaluation?
- A
Test images cannot be converted to tensors if they are resized.
- B
Random transformations prevent the model from entering evaluation mode.
- C
The test loader uses augmentation to calculate training gradients.
- D
Evaluation should measure predictions on the intended test images, not randomly altered versions of them.
Correct answer
DEvaluation should measure predictions on the intended test images, not randomly altered versions of them.
Explanation
Training augmentation adds variety, but evaluation should assess predictions on the specific test examples rather than random transformations of them.
- A
- 80
What is sequential data?
- A
Data whose values are all generated independently from one another.
- B
Data whose rows can always be randomly rearranged without changing their meaning.
- C
Data containing only images with three color channels.
- D
Data in which the order of points matters and may encode temporal or spatial dependencies.
Correct answer
DData in which the order of points matters and may encode temporal or spatial dependencies.
Explanation
Sequential data has meaningful ordering; examples include time series, text, and audio.
- A
- 81
Why can randomly splitting sequential data create lookahead bias?
- A
Random splitting necessarily removes every target value from the training set.
- B
Training may include information from times later than examples used for testing or forecasting.
- C
Training on randomly selected points prevents the use of recurrent models.
- D
Random splitting makes all sequential data independent of its timestamps.
Correct answer
BTraining may include information from times later than examples used for testing or forecasting.
Explanation
A random split can expose the model to future information while it is being trained to predict earlier points, creating unrealistic forecasts.
- A
- 82
What is a safer train-test split strategy for forecasting a time series?
- A
Randomly distribute observations from every time period between both sets.
- B
Train on the last part of the series and test on the first part.
- C
Train on earlier observations and test on later observations.
- D
Place every other observation in the training set and discard timestamps.
Correct answer
CTrain on earlier observations and test on later observations.
Explanation
Splitting by time preserves the forecasting direction: training uses earlier data and testing uses later data.
- A
- 83
If consumption is recorded every 15 minutes, how many observations represent the previous 24 hours?
- A
Twenty-four observations.
- B
Ninety-six observations.
- C
One hundred forty-four observations.
- D
Sixty observations.
Correct answer
BNinety-six observations.
Explanation
There are four 15-minute intervals per hour, so 24 hours contain 24 times 4, or 96, observations.
- A
- 84
In the described next-step forecasting setup, what is the target for each input sequence?
- A
The last input point copied into a separate class label.
- B
The first data point before the sequence.
- C
The data point immediately after the sequence.
- D
The average of every data point in the entire dataset.
Correct answer
CThe data point immediately after the sequence.
Explanation
Each training example uses a sequence of past values as input and the subsequent data point as its target.
- A
- 85
What distinguishes a recurrent neural network from a feedforward network?
- A
A recurrent network passes a hidden state from one timestep to the next.
- B
A recurrent network sends all predictions directly back to the input dataset.
- C
A recurrent network has no learned weights or activation functions.
- D
A recurrent network processes each timestep independently without retaining information.
Correct answer
AA recurrent network passes a hidden state from one timestep to the next.
Explanation
RNNs pass a hidden state forward through time, allowing later outputs to depend on earlier inputs.
- A
- 86
What is typically used as the initial hidden state at the first RNN timestep?
- A
The model's highest predicted class.
- B
The final target label in the sequence.
- C
A random permutation of all input features.
- D
A tensor of zeros.
Correct answer
DA tensor of zeros.
Explanation
Because there is no previous hidden state at the first timestep, it is typically initialized to zero.
- A
- 87
Which RNN architecture reads a sequence but uses only its final output?
- A
Sequence-to-vector.
- B
Sequence-to-sequence.
- C
Vector-to-sequence.
- D
Encoder-decoder.
Correct answer
ASequence-to-vector.
Explanation
A sequence-to-vector model processes an input sequence and uses its final output to produce a vector-level prediction, such as a text classification.
- A
- 88
Which RNN architecture uses outputs at every timestep while receiving a sequence?
- A
Sequence-to-vector.
- B
Vector-to-sequence.
- C
Sequence-to-sequence.
- D
Encoder-decoder.
Correct answer
CSequence-to-sequence.
Explanation
Sequence-to-sequence models produce and use outputs at each timestep, as in real-time speech recognition.
- A
- 89
Which architecture can generate a sequence from a single input vector?
- A
Vector-to-sequence.
- B
Sequence-to-vector.
- C
Time-to-class.
- D
Sequence-to-sequence.
Correct answer
AVector-to-sequence.
Explanation
A vector-to-sequence architecture takes one vector and makes use of outputs at multiple timesteps, such as in text generation.
- A
- 90
Why does an encoder-decoder architecture process the input sequence before beginning output generation?
- A
It must discard all hidden states before each output is generated.
- B
It uses the input sequence only to determine the number of model layers.
- C
It cannot generate any outputs unless the input contains only one timestep.
- D
Some tasks, such as translation, require the entire input to be considered before producing the output sequence.
Correct answer
DSome tasks, such as translation, require the entire input to be considered before producing the output sequence.
Explanation
Unlike sequence-to-sequence processing that produces outputs as inputs arrive, an encoder-decoder can wait until the full input is processed, as translation often requires.
- A
- 91
What is the short-term memory problem of a plain RNN?
- A
Information from early inputs may fade from the hidden state by the time a long sequence is processed.
- B
The model permanently stores every input and cannot make predictions.
- C
The model produces only a single output for all possible tasks.
- D
The model cannot accept inputs that contain more than one feature.
Correct answer
AInformation from early inputs may fade from the hidden state by the time a long sequence is processed.
Explanation
Plain RNNs can struggle to retain information from the beginning of long sequences, motivating cells such as LSTM and GRU.
- A
- 92
How does an LSTM represent short-term and long-term memory?
- A
It uses the cell state for short-term memory and the input sequence for long-term memory.
- B
It uses the learning rate as short-term memory and momentum as long-term memory.
- C
It uses a hidden state for short-term memory and a cell state for long-term memory.
- D
It uses two output labels and no hidden state.
Correct answer
CIt uses a hidden state for short-term memory and a cell state for long-term memory.
Explanation
The LSTM cell uses hidden state h for short-term memory and cell state c for long-term memory.
- A
- 93
What do the forget, input, and output gates of an LSTM help control?
- A
Which dataset samples to shuffle, which batch to discard, and which class to label.
- B
Which loss function to minimize, which optimizer to use, and which metric to report.
- C
How many layers to create, how many features to accept, and how many epochs to run.
- D
What long-term information to erase, what information to store, and what current output to produce.
Correct answer
DWhat long-term information to erase, what information to store, and what current output to produce.
Explanation
The gates regulate what to forget from long-term memory, what to add to it, and what to produce as the current output.
- A
- 94
How does a GRU differ from an LSTM as described?
- A
A GRU is a dense layer that predicts only a single class.
- B
A GRU adds a separate long-term cell state and more gates than an LSTM.
- C
A GRU merges long- and short-term memory into one hidden state and does not use an output gate.
- D
A GRU has no hidden state and cannot process sequences.
Correct answer
CA GRU merges long- and short-term memory into one hidden state and does not use an output gate.
Explanation
The GRU is a simplified LSTM variant that uses one hidden state and lacks the LSTM's output gate.
- A
- 95
When might a GRU be preferred over an LSTM?
- A
When its comparable performance is achieved with lower computational complexity.
- B
When the input is not sequential and contains no ordered data.
- C
When a model must use a separate long-term cell state.
- D
When the task requires an output gate that only LSTMs provide.
Correct answer
AWhen its comparable performance is achieved with lower computational complexity.
Explanation
GRUs are less complex than LSTMs and may require less computation; their relative performance depends on the use case, so comparing both can be useful.
- A
- 96
Why might the time dimension of a sequence batch need to be expanded before it is passed to an RNN?
- A
Recurrent layers require every sequence to be converted into a class label.
- B
Recurrent layers expect batch size, sequence length, and feature dimensions, even when there is only one feature.
- C
Expanding the tensor adds more observations to each sequence.
- D
The extra dimension stores the model's hidden layers.
Correct answer
BRecurrent layers expect batch size, sequence length, and feature dimensions, even when there is only one feature.
Explanation
RNN, LSTM, and GRU inputs require batch, sequence, and feature dimensions; a single-feature sequence may need an added feature dimension.
- A
- 97
Why might model outputs be squeezed before calculating a regression loss?
- A
To convert continuous predictions into class probabilities.
- B
To make their shape match the target tensor's shape.
- C
To add a feature dimension required by the recurrent layer.
- D
To increase the sequence length to match the batch size.
Correct answer
BTo make their shape match the target tensor's shape.
Explanation
Loss functions expect their inputs to have matching shapes; squeezing can remove an extra singleton output dimension.
- A
- 98
What is object-oriented programming in the described context?
- A
A training technique that uses objects instead of tensors.
- B
A method for converting all Python functions into neural network layers.
- C
A way to split a model's predictions into input and target arrays.
- D
A way to define objects with attributes that store data and methods that perform tasks.
Correct answer
DA way to define objects with attributes that store data and methods that perform tasks.
Explanation
Object-oriented programming defines objects with attributes for data and methods for actions or tasks.
- A
- 99
What is the purpose of a class's
__init__method?- A
It converts an object's methods into target labels.
- B
It runs when an object is created and can initialize that object's attributes.
- C
It runs after every optimizer step to calculate accuracy.
- D
It executes only when a dataset is shuffled.
Correct answer
BIt runs when an object is created and can initialize that object's attributes.
Explanation
The initialization method is called when an object is created and can assign values, such as a balance, to its attributes.
- A
- 100
Why define a custom PyTorch dataset class?
- A
It guarantees that every sample has the same label.
- B
It replaces the model's forward method with a data loader.
- C
It can specify how data is loaded, how many samples it contains, and what each indexed sample returns.
- D
It automatically selects the optimizer and tunes the learning rate.
Correct answer
CIt can specify how data is loaded, how many samples it contains, and what each indexed sample returns.
Explanation
A custom dataset implements initialization and methods for reporting its length and retrieving an indexed sample.
- A
- 101
In a PyTorch model class, what is the role of the
forwardmethod?- A
It resets the model's weights after each batch.
- B
It describes how inputs pass through the model's layers to produce outputs.
- C
It initializes the optimizer's learning rate and momentum.
- D
It loads the dataset and assigns class labels to its files.
Correct answer
BIt describes how inputs pass through the model's layers to produce outputs.
Explanation
The forward method defines the computation performed when inputs are passed through the model.
- A
- 102
What is the advantage of defining a PyTorch model as a class rather than using only a simple sequential container?
- A
A class guarantees higher accuracy than every sequential model.
- B
A class eliminates the need to define model layers.
- C
A class offers more flexibility for customized model behavior as complexity grows.
- D
A class automatically performs data augmentation and evaluation.
Correct answer
CA class offers more flexibility for customized model behavior as complexity grows.
Explanation
Sequential models can be convenient for small models, while class-based models provide more flexibility for customization.
- A
- 103
What is a common purpose of a multi-input model?
- A
To replace model inputs with multiple loss functions.
- B
To force a model to predict only one class from one input feature.
- C
To divide a single image into separate training and test sets.
- D
To combine information from multiple sources, such as an image and accompanying text.
Correct answer
DTo combine information from multiple sources, such as an image and accompanying text.
Explanation
Multi-input models can combine sources such as multiple images or different modalities, including image and text.
- A
- 104
How does the described two-input character classifier use its inputs?
- A
It processes the character image and alphabet vector separately, concatenates their representations, then classifies.
- B
It converts the image into a label and discards the alphabet vector before classification.
- C
It concatenates the raw image and target label, then predicts the alphabet vector.
- D
It uses the alphabet vector to resize the image and omits the classifier.
Correct answer
AIt processes the character image and alphabet vector separately, concatenates their representations, then classifies.
Explanation
The model processes the image and alphabet information with separate subnetworks, concatenates their representations, and uses a classifier to predict the character.
- A
- 105
What does tensor concatenation do?
- A
It joins tensors along a specified dimension.
- B
It multiplies every tensor element by its class label.
- C
It averages tensors and removes their dimensions.
- D
It converts every tensor value to a one-hot vector.
Correct answer
AIt joins tensors along a specified dimension.
Explanation
Tensor concatenation joins tensors along the dimension specified by the operation.
- A
- 106
What is a multi-label classification problem?
- A
A model predicts several numerical values but no classes.
- B
An input may belong to multiple classes at the same time.
- C
A model uses several input sources but has only one output.
- D
An input must belong to exactly one of two classes.
Correct answer
BAn input may belong to multiple classes at the same time.
Explanation
In multi-label classification, an example can have several labels simultaneously, such as an image containing both a beach and people.
- A
- 107
Why might a very deep model use additional outputs after intermediate blocks?
- A
They reduce the model to a single linear layer.
- B
They replace the need to provide target labels during training.
- C
They ensure that the model ignores its final output layer.
- D
They encourage earlier layers to learn task-relevant features and can act as regularization.
Correct answer
DThey encourage earlier layers to learn task-relevant features and can act as regularization.
Explanation
Intermediate outputs can encourage earlier parts of a deep model to learn useful features and may improve robustness through regularization.
- A
- 108
How is the total loss commonly formed for a model with two output tasks?
- A
Use accuracy as the loss for one task and ignore the other task.
- B
Average the model's output probabilities without comparing targets.
- C
Calculate a loss for only the output with the most classes.
- D
Calculate a loss for each output and combine the losses, often by summing them.
Correct answer
DCalculate a loss for each output and combine the losses, often by summing them.
Explanation
Each output has its own target and loss; the losses can be combined, for example by summing them, to create an optimization objective.
- A
- 109
If character classification is twice as important as alphabet classification, how can this be reflected in a combined loss?
- A
Give the character loss twice the weight of the alphabet loss.
- B
Remove the alphabet loss and double the model's output size.
- C
Give the alphabet loss twice the weight of the character loss.
- D
Divide both losses by the number of training samples and ignore their relative importance.
Correct answer
AGive the character loss twice the weight of the alphabet loss.
Explanation
Loss weights express the relative importance of tasks; a more important character-classification loss can be assigned a larger weight.
- A
- 110
Why can combining an MSE loss for house prices with a much smaller cross-entropy loss be problematic?
- A
Cross-entropy cannot be used with a model that also predicts continuous values.
- B
The optimizer cannot update a model that has two output layers.
- C
MSE always converts the classification output into a regression target.
- D
The much larger MSE may dominate the combined objective, causing the model to neglect the quality-classification task.
Correct answer
DThe much larger MSE may dominate the combined objective, causing the model to neglect the quality-classification task.
Explanation
If loss magnitudes are on very different scales, the larger loss can dominate optimization and effectively cause the model to ignore the smaller one.
- A
- 111
How can differently scaled loss components be brought to more comparable ranges?
- A
Replace each loss with the model's parameter count.
- B
Multiply the larger loss by a still larger constant.
- C
Scale each loss, for example by dividing by the maximum value in its batch.
- D
Convert all continuous targets into class indices.
Correct answer
CScale each loss, for example by dividing by the maximum value in its batch.
Explanation
The material describes scaling losses by dividing by a batch maximum to bring them into a more comparable range before combining or weighting them.
- A
- 112
What is the recommended first check when beginning work on a new deep learning problem?
- A
Run a large hyperparameter search before building the model.
- B
Try to overfit a single training example to verify the problem and implementation are workable.
- C
Train on the complete dataset without checking a forward pass.
- D
Apply the strongest possible regularization and evaluate only the test set.
Correct answer
BTry to overfit a single training example to verify the problem and implementation are workable.
Explanation
Training on one example can expose bugs and check that the problem is solvable; a correctly configured model should quickly fit it closely.
- A
- 113
After confirming that a model can fit one example, what is a sensible next step?
- A
Freeze every layer and evaluate only on the validation set.
- B
Tune exclusively on the test set before completing training.
- C
Scale training to the full training set using a model large enough to overfit initially.
- D
Reduce the model until it cannot fit the training examples.
Correct answer
CScale training to the full training set using a model large enough to overfit initially.
Explanation
Once the single-example check works, train on the full training set with a sufficiently capable model to establish that the task can be learned.
- A
- 114
What is transfer learning?
- A
Reusing a model trained on one task as a starting point for a second task.
- B
Transferring loss values from a classification task into an accuracy metric.
- C
Moving a dataset from the training set into the validation set.
- D
Copying predictions from a test set into the model's target labels.
Correct answer
AReusing a model trained on one task as a starting point for a second task.
Explanation
Transfer learning reuses a model trained on an initial task, such as by loading its weights to start training on a new dataset.
- A
- 115
What characterizes fine-tuning in the described transfer-learning setup?
- A
Starting from previously trained weights and training on a related task with a smaller learning rate.
- B
Freezing every layer and avoiding all further training.
- C
Changing the dataset labels without updating the model.
- D
Starting from random weights and using a larger learning rate on an unrelated task.
Correct answer
AStarting from previously trained weights and training on a related task with a smaller learning rate.
Explanation
Fine-tuning reuses pretrained weights for a related task and typically uses a smaller learning rate.
- A
- 116
Which layers are commonly frozen first when fine-tuning a model?
- A
Only layers that have no weights or biases.
- B
Earlier layers, while layers nearer the output are more likely to be fine-tuned.
- C
Every layer, because freezing is required for fine-tuning.
- D
Only the final output layer, while earlier layers are always trained.
Correct answer
BEarlier layers, while layers nearer the output are more likely to be fine-tuned.
Explanation
A rule of thumb is to freeze early layers and fine-tune layers closer to the output, where task-specific changes are more likely to be useful.
- A
- 117
What does setting a parameter's
requires_gradattribute to false do in the described freezing workflow?- A
It makes the parameter determine the model's batch size.
- B
It changes the parameter into a target label.
- C
It prevents that parameter from receiving gradient-based updates.
- D
It forces the parameter to take a random value in every batch.
Correct answer
CIt prevents that parameter from receiving gradient-based updates.
Explanation
A parameter with gradient tracking disabled is not trained through gradient-based updates, which is how selected layers can be frozen.
- A
- 118
What is the goal of the model-development strategy of first overfitting and then reducing overfitting?
- A
Verify the task is learnable, then use validation performance to guide improvements in generalization.
- B
Avoid using validation data until after the test set is evaluated.
- C
Ensure the final model memorizes the training set as accurately as possible.
- D
Choose the model with the largest training loss and smallest capacity.
Correct answer
AVerify the task is learnable, then use validation performance to guide improvements in generalization.
Explanation
The strategy first checks that the model can learn the task, then applies measures to improve validation performance and generalization.
- A
- 119
How does grid search explore hyperparameters?
- A
It changes parameters according to class labels in the test set.
- B
It selects one random value and never evaluates alternatives.
- C
It automatically adds new model layers after each epoch.
- D
It evaluates specified parameter values at fixed intervals.
Correct answer
DIt evaluates specified parameter values at fixed intervals.
Explanation
Grid search tests predefined values, such as selected learning rates and momentum values.
- A
- 120
How does random search differ from grid search?
- A
It searches only over the number of output classes.
- B
It tests every possible value in a fixed interval.
- C
It samples parameter values from a range rather than testing only a fixed set of values.
- D
It changes model parameters without measuring validation performance.
Correct answer
CIt samples parameter values from a range rather than testing only a fixed set of values.
Explanation
Random search selects values randomly within defined ranges and can explore a broader variety of settings without testing every grid point.
- A
- 121
What does small weight initialization help prevent?
- A
Unstable or extreme layer outputs that can slow training.
- B
The use of activation functions in hidden layers.
- C
The model from ever producing a nonzero gradient.
- D
The creation of input features in the dataset.
Correct answer
AUnstable or extreme layer outputs that can slow training.
Explanation
Small weights, together with appropriately scaled inputs, help keep weighted sums stable rather than producing extreme values.
- A
- 122
What variance properties should a suitable layer initialization aim to maintain?
- A
Input and output variances should be close, and gradient variance should remain similar across the layer.
- B
Input variance should be much larger than output variance, regardless of activation.
- C
Output variance should always be zero, and gradient variance should always increase.
- D
Both input and gradient variances should change unpredictably between layers.
Correct answer
AInput and output variances should be close, and gradient variance should remain similar across the layer.
Explanation
The material describes initialization methods that aim to preserve the variance of activations and gradients across layers.
- A
- 123
Why is He initialization used with ReLU and similar activations?
- A
It is designed to provide appropriate variance properties for layers using those activations.
- B
It prevents the model from using bias parameters.
- C
It replaces backpropagation with a fixed parameter update.
- D
It converts ReLU outputs into class probabilities.
Correct answer
AIt is designed to provide appropriate variance properties for layers using those activations.
Explanation
He initialization is described as an appropriate initialization method for ReLU and similar activation functions.
- A
- 124
What is the dying-neuron problem associated with standard ReLU?
- A
A neuron produces unbounded gradients for every negative input.
- B
A neuron permanently outputs one for all positive inputs.
- C
A neuron may output zero for negative inputs and receive no useful gradient to resume learning.
- D
A neuron cannot be used in any layer with learned weights.
Correct answer
CA neuron may output zero for negative inputs and receive no useful gradient to resume learning.
Explanation
Because ReLU is zero for negative inputs, a neuron can stop learning if its inputs remain negative.
- A
- 125
Why can ELU help address a drawback of ReLU?
- A
It outputs zero for every negative value and therefore eliminates negative gradients.
- B
It removes the need for layer initialization.
- C
It converts all outputs into a probability distribution.
- D
It has nonzero gradients for negative values and an average output near zero.
Correct answer
DIt has nonzero gradients for negative values and an average output near zero.
Explanation
ELU is described as having nonzero gradients for negative inputs and an average output near zero, helping address dying neurons and gradient issues.
- A
- 126
What operations define batch normalization in the described process?
- A
Multiply by the batch mean, add the standard deviation, then remove all learned parameters.
- B
Subtract the batch mean, divide by the standard deviation, then learnable scaling and shifting.
- C
Drop half the inputs, freeze the layer, and replace its gradients with zeros.
- D
Convert the batch to class indices, sort it, and apply a softmax.
Correct answer
BSubtract the batch mean, divide by the standard deviation, then learnable scaling and shifting.
Explanation
Batch normalization first normalizes outputs using their mean and standard deviation, then learns scale and shift parameters.
- A
- 127
Where is a batch-normalization layer placed in the described model construction?
- A
Between the optimizer and the test DataLoader.
- B
Before the input data, with an input size unrelated to preceding layers.
- C
After the final loss function, with one input for every target label.
- D
After a layer whose output size matches the batch-normalization input size, before the activation.
Correct answer
DAfter a layer whose output size matches the batch-normalization input size, before the activation.
Explanation
The example passes a linear layer's output into batch normalization and then sends the result to the activation function; the normalization input size must match the preceding output size.
- A
- 128
What problem can occur when gradients vanish in earlier layers?
- A
Those layers receive excessively large updates and diverge.
- B
Those layers automatically gain more output classes.
- C
Those layers stop passing input data to the forward pass.
- D
Those layers receive very small updates and learn poorly.
Correct answer
DThose layers receive very small updates and learn poorly.
Explanation
Vanishing gradients become smaller during backpropagation, so earlier layers may receive hardly any parameter updates.
- A
- 129
What problem can occur when gradients explode?
- A
Parameter updates become excessively large and training can diverge.
- B
Parameter updates become too small for early layers to learn.
- C
The model's input tensors lose their feature dimension.
- D
The model's predicted classes become uniformly distributed.
Correct answer
AParameter updates become excessively large and training can diverge.
Explanation
Exploding gradients grow increasingly large, leading to huge parameter updates and potentially divergent training.
- A
- 130
Why can careful initialization and activation choices be insufficient on their own to prevent gradient instability?
- A
Initialization and activations affect only the test set, not training.
- B
Appropriate activations prevent the model from calculating any gradients.
- C
Initial weights are never used once a forward pass begins.
- D
Unstable gradients can return during training even if the model starts with suitable weights and activations.
Correct answer
DUnstable gradients can return during training even if the model starts with suitable weights and activations.
Explanation
Good initialization and activations can alleviate instability at the start, but batch normalization may also help because problems can recur during training.
- A
- 131
Which combination is presented as a three-part approach to gradient instability?
- A
Dropout, one-hot encoding, and a larger batch size only.
- B
Random data splits, softmax in every layer, and fixed weights.
- C
Appropriate weight initialization, suitable activations, and batch normalization.
- D
A larger test set, more output classes, and lower accuracy.
Correct answer
CAppropriate weight initialization, suitable activations, and batch normalization.
Explanation
The described three-step solution consists of proper weight initialization, good activation choices, and batch normalization.
- A

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