This section checks whether you can connect a short calculation or code fragment to the mathematics in this unit. The goal is not to memorize Python. The goal is to identify the objects, check the shapes, and interpret the mathematical operation.
The learning rate is alpha. The vector grad_f(x) must have the same shape as x, since the update subtracts one vector from another. If the minus sign were replaced by a plus sign, the update would move in the direction of steepest increase instead of steepest decrease. The loop does not prove that a minimum has been found. It only describes the repeated update; convergence depends on the function, starting point, learning rate, and stopping rule.
The learning rate \(\alpha=0.05\) is making slow but steady progress. The learning rate \(\alpha=0.20\) is making faster useful progress. The learning rate \(\alpha=1.05\) appears unstable because the loss is increasing. A decreasing loss table does not prove that the global minimum has been found. It only shows what happened for the displayed iterates.
The matrix being studied is the Hessian matrix. Its eigenvalues have opposite signs, so the quadratic form \(\mathbf{h}^T H\mathbf{h}\) takes both positive and negative values. If \(H\) is the Hessian at a critical point, the second derivative test classifies the critical point as a saddle point. The phrase "at a critical point" is important because the Hessian test classifies local behavior after the first-order term has disappeared.
The expression A.T @ r checks whether the residual is orthogonal to the columns of \(A\text{.}\) It can be close to zero even when r is not close to zero. Unit 4 used this same residual-orthogonality condition to derive the normal equations. Unit 5 obtains the same equations by setting the gradient of \(\|A\mathbf{x}-\mathbf{b}\|^2\) equal to zero.
This is a least-squares problem because the prediction vector is \(A\mathbf{c}\text{,}\) and training chooses \(\mathbf{c}\) so that \(A\mathbf{c}\) is close to \(\mathbf{y}\text{.}\) The model is not linear as a function of \(t\text{,}\) because it contains \(\tanh(t)\text{,}\)\(\tanh(t-1)\text{,}\) and \(\tanh(t+1)\text{.}\) It is linear as a function of \(\mathbf{c}\text{,}\) which is why least squares applies.
The matrix G has shape \(m\times d\text{.}\) The command np.outer(g, h) forms the matrix \(\mathbf{g}\mathbf{h}^T\text{.}\) This is the correct outer product when g and h are stored as one-dimensional NumPy arrays. The second line represents the update
. Focus on four reading habits: identify the gradient descent update, diagnose a learning-rate table, recognize a least-squares call, and identify the fixed feature columns in the design matrix.
For a quick reference on Python loops, helper functions, entrywise functions, design matrices, eigenvalue and least-squares commands, transposes, and numerical checks such as "close to zero," see the programming appendix sections B.12, B.4, B.8, B.10, and B.9.
Exam skill. Given a short Unit 5 code snippet, loss table, or matrix output, identify the mathematical operation and interpret the result as a descent step, Hessian/eigenvalue check, least-squares fit, residual-orthogonality check, fixed-feature training problem, or rank-one update. Tags.[U5-LO2, U5-LO3, U5-LO4, U5-LO5, U5-LO6, U5-LO7 | C+M+T | Core]