Gradient Descent
- 46Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What kinds of quantities can Gradient Descent optimize in statistics and machine learning?
46 questions
- 1
What kinds of quantities can Gradient Descent optimize in statistics and machine learning?
Model answer
Gradient Descent can optimize parameters and structures such as the intercept and slope of a linear regression line, the curve in logistic regression, and clusters in t-SNE.
Explanation
The method is presented as a general optimization strategy that applies to many problems, not just fitting a line.
- 2
What is the goal of using Gradient Descent to fit a linear regression line?
Model answer
The goal is to find the parameter values for the intercept and slope that produce the best-fitting line.
Explanation
Gradient Descent searches for parameter values that minimize a chosen loss function.
- 3
Why can learning Gradient Descent on a line help with other optimization problems?
Model answer
The same general strategy—using derivatives to take steps toward a minimum—can optimize more complicated models and loss functions.
Explanation
The example uses a line to illustrate a strategy that also applies to logistic regression, t-SNE, and other problems.
- 4
What is a loss function in the context of Gradient Descent?
Model answer
A loss function measures how well a model fits the data by assigning a value to its errors.
Explanation
In the example, the sum of the squared residuals serves as the loss function.
- 5
Why is the sum of the squared residuals useful for evaluating a fitted line?
Model answer
It combines the squared prediction errors into one value, allowing different parameter choices to be compared.
Explanation
A smaller sum of squared residuals indicates that the line fits the observed data better.
- 6
How does the brute-force plug-and-chug approach differ from Gradient Descent?
Model answer
Plug-and-chug evaluates many possible parameter values, whereas Gradient Descent uses derivatives to take strategically sized steps toward the minimum.
Explanation
Gradient Descent takes relatively large steps when far from the optimum and smaller steps when near it.
- 7
Why is Gradient Descent useful when setting a derivative equal to zero is difficult or impossible?
Model answer
It can approach the minimum by repeatedly taking steps based on the derivative without requiring an algebraic solution to the equation where the derivative equals zero.
Explanation
This makes the method applicable to many optimization problems that cannot be solved directly.
- 8
What does the minimum of a loss function represent when fitting a model?
Model answer
It represents the parameter values that produce the smallest loss and therefore the best fit according to that loss function.
Explanation
For the line-fitting example, the minimum is the smallest possible sum of squared residuals.
- 9
What is a residual in linear regression?
Model answer
A residual is the difference between an observed response and the response predicted by the fitted line.
Explanation
For example, when the observed height is 1.4 and the predicted height is 0.32, the residual is approximately 1.1.
- 10
Using the slope estimate 0.64 and an intercept of 0, what height does the line predict for a person weighing 0.5?
Model answer
The predicted height is 0.32, using the line equation y=0+0.64(0.5).
Explanation
The prediction is obtained by substituting the person's weight into the line equation.
- 11
How is the sum of squared residuals calculated for a candidate line?
Model answer
Calculate each residual, square each residual, and add the squared values together.
Explanation
The resulting total is used as the loss value for that candidate line.
- 12
What do the axes represent on a graph of the sum of squared residuals against the intercept?
Model answer
The horizontal axis represents different intercept values, and the vertical axis represents the corresponding sum of squared residuals.
Explanation
Each point shows how well a line with a particular intercept fits the data.
- 13
What does the lowest point on the intercept-loss graph indicate?
Model answer
It indicates the intercept value that gives the smallest sum of squared residuals among the values considered.
Explanation
The graph can reveal whether a tested intercept is better than other tested choices.
- 14
Why might evaluating only several intercept values fail to find the best intercept?
Model answer
The true minimum may lie between the tested intercept values.
Explanation
Testing additional values could locate the minimum, but this can be slow and inefficient.
- 15
Why can the slope of the loss curve be used to guide the search for the best intercept?
Model answer
The slope indicates the direction and relative distance from the minimum: slopes far from zero suggest larger moves, while slopes near zero suggest smaller moves.
Explanation
At the minimum, the derivative of the loss with respect to the intercept is zero or very close to zero.
- 16
What happens to the residuals when the intercept changes from 0 to a value closer to the optimum, such as 0.57?
Model answer
The residuals generally shrink, causing the sum of squared residuals to decrease.
Explanation
Moving the intercept toward its optimal value improves the line's fit to the observed heights.
- 17
What values for the intercept and slope produced the best-fitting line in the example?
Model answer
The best-fitting line had an intercept of approximately 0.95 and a slope of approximately 0.64.
Explanation
These values matched the estimates obtained using least squares.
- 18
Why is a random initial parameter value used in Gradient Descent?
Model answer
It provides an initial guess from which the algorithm can begin improving the model.
Explanation
The initial intercept and slope do not need to be optimal; they only need to give the algorithm a starting point.
- 19
What derivative is calculated when Gradient Descent is used to optimize only the intercept?
Model answer
The derivative of the loss function, such as the sum of squared residuals, with respect to the intercept is calculated.
Explanation
This derivative gives the slope of the loss curve at the current intercept.
- 20
Why is the chain rule needed when differentiating the squared residual terms?
Model answer
Each term is a squared expression containing the intercept, so the chain rule differentiates both the outer square and the expression inside it.
Explanation
The derivative begins by bringing down the exponent and multiplying by the derivative of the inner expression.
- 21
What does the derivative of the loss with respect to the intercept represent geometrically?
Model answer
It represents the slope of the loss curve at the current intercept value.
Explanation
A negative derivative means the curve is decreasing at that point, while a derivative near zero indicates proximity to the minimum.
- 22
How is the step size determined in Gradient Descent?
Model answer
The step size is calculated by multiplying the current derivative, or slope, by the learning rate.
Explanation
The learning rate scales the derivative so that the resulting update is not too large.
- 23
How is a new parameter value calculated from an old value and a step size?
Model answer
The new parameter equals the old parameter minus the step size.
Explanation
For example, an old intercept of 0 and a step size of −0.57 produce a new intercept of 0.57.
- 24
What happened during the first intercept update in the example?
Model answer
At an intercept of 0, the derivative was approximately −5.7, producing a step of −0.57 with a learning rate of 0.1 and a new intercept of 0.57.
Explanation
Subtracting the negative step from the old intercept moves the intercept upward toward the minimum.
- 25
What happened during the second intercept update in the example?
Model answer
At an intercept of 0.57, the derivative was approximately −2.3, producing a step of −0.23 and a new intercept of about 0.8.
Explanation
The second update was smaller because the current slope was closer to zero.
- 26
Why did the intercept updates become progressively smaller?
Model answer
As the intercept approached the minimum of the loss curve, the derivative moved closer to zero, reducing the step size.
Explanation
The sequence moved from larger changes, such as 0 to 0.57, to smaller changes near the optimum.
- 27
What is the effect of choosing a step that is excessively large?
Model answer
An excessively large step can move past the minimum and increase the loss instead of decreasing it.
Explanation
The learning rate helps prevent the derivative-based step from becoming too large.
- 28
What is the learning rate, and what role does it play?
Model answer
The learning rate is a small number that scales the derivative to determine the size of each parameter update.
Explanation
A suitable learning rate allows large progress when appropriate while reducing the risk of overshooting the minimum.
- 29
Why should Gradient Descent take small steps when the derivative is close to zero?
Model answer
A derivative close to zero indicates that the algorithm is near the minimum, so large steps could overshoot the optimal value.
Explanation
Small updates allow the algorithm to settle near the bottom of the loss curve.
- 30
What stopping condition based on step size is used by Gradient Descent?
Model answer
Gradient Descent stops when the step size becomes sufficiently close to zero, such as 0.001 or smaller.
Explanation
A very small step indicates that the derivative is near zero and further updates are unlikely to improve the solution substantially.
- 31
If the derivative is 0.009 and the learning rate is 0.1, should the algorithm stop under a minimum step-size threshold of 0.001?
Model answer
Yes. The step size is 0.0009, which is smaller than the threshold of 0.001.
Explanation
The step size is calculated as 0.009imes0.1=0.0009.
- 32
Why does Gradient Descent also impose a maximum number of steps?
Model answer
The maximum limits computation and ensures that the algorithm stops even if the step size never becomes sufficiently small.
Explanation
In practice, the maximum may be 1000 steps or more.
- 33
What is the practical effect of using an unsuitable learning rate when optimizing both intercept and slope?
Model answer
Gradient Descent may fail to reach the correct solution even after many steps.
Explanation
The two-parameter example required a smaller learning rate than the intercept-only example, showing that the method can be sensitive to this choice.
- 34
How can a reasonable learning rate be selected automatically in practice?
Model answer
It can be started at a relatively large value and gradually reduced with each step.
Explanation
This approach can provide faster movement early in optimization and more stable, smaller updates later.
- 35
Why are two derivatives needed when optimizing both the intercept and the slope?
Model answer
One derivative measures how the loss changes with the intercept, and the other measures how it changes with the slope.
Explanation
Each parameter requires its own derivative so that it can receive an appropriate update.
- 36
When differentiating with respect to the intercept, how is the slope treated?
Model answer
The slope is treated as a constant, so its derivative with respect to the intercept is zero.
Explanation
Only terms that vary with the intercept contribute to the derivative with respect to the intercept.
- 37
When differentiating with respect to the slope, how is the intercept treated?
Model answer
The intercept is treated as a constant, so its derivative with respect to the slope is zero.
Explanation
The derivative with respect to the slope includes the input weights because the slope is multiplied by weight.
- 38
Why do the weights appear in the derivative with respect to the slope?
Model answer
Because the slope is multiplied by each weight in the line equation, differentiating with respect to the slope leaves the corresponding weight as a factor.
Explanation
For the three samples, the relevant weight factors are 0.5, 2.3, and 2.9.
- 39
What is a gradient when a function has two or more derivatives?
Model answer
A gradient is the collection of the function's derivatives with respect to its parameters.
Explanation
For the line-fitting example, the gradient contains the derivative with respect to the intercept and the derivative with respect to the slope.
- 40
How does Gradient Descent update two parameters simultaneously?
Model answer
It evaluates both derivatives, uses the learning rate to calculate a step size for each parameter, and subtracts each step from its corresponding old parameter.
Explanation
The intercept and slope are updated separately using their respective components of the gradient.
- 41
What changes in Gradient Descent when a model has more than two parameters?
Model answer
The algorithm takes one derivative for each additional parameter, while the rest of the procedure remains the same.
Explanation
Each parameter receives an update based on its corresponding derivative.
- 42
State the general steps of the Gradient Descent algorithm.
Model answer
Take the derivative of the loss with respect to every parameter, choose initial parameter values, evaluate the derivatives, calculate step sizes, update the parameters, and repeat until the steps are small or the maximum number of steps is reached.
Explanation
These steps generalize the intercept-only and intercept-and-slope examples to other loss functions and models.
- 43
Does Gradient Descent require the sum of squared residuals as its loss function?
Model answer
No. The sum of squared residuals is only one possible loss function; Gradient Descent can use other loss functions for other types of data.
Explanation
The procedure remains the same: compute derivatives, calculate updates, and repeat until a stopping condition is met.
- 44
What is Stochastic Gradient Descent?
Model answer
Stochastic Gradient Descent uses a randomly selected subset of the data at each step instead of the full data set.
Explanation
Using a subset reduces the amount of computation needed to calculate the derivatives.
- 45
Why is Stochastic Gradient Descent useful with very large data sets?
Model answer
It can reduce the time required to calculate loss derivatives by using only a randomly selected subset of the data at each update.
Explanation
This is especially helpful when the full data set contains millions of observations.
- 46
Compare ordinary Gradient Descent with Stochastic Gradient Descent in terms of data usage per step.
Model answer
Ordinary Gradient Descent uses the full data set for each step, whereas Stochastic Gradient Descent uses a randomly selected subset.
Explanation
The subset-based approach reduces computation per step while preserving the general update strategy.

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