To find the closed form solution for the least-square loss, we can first rewrite the objective function using matrices. Let \mY∈RN×d be the matrix representation of the target output, where each row corresponds to a data point's target output \vtn. Let \mXext∈RN×(D+1) be the extended feature matrix obtained by appending a column of ones to the input feature matrix \mX. Then we have:
\begin{align*}
\mY =
\begin{bmatrix}
\vt_1 \
\vdots\
\vt_N
\end{bmatrix}, \quad
\mX_{\text{ext}} =
\begin{bmatrix}
-\vx_1^\top-, 1 \
\vdots\
-\vx_N^\top-, 1
\end{bmatrix}
\end{align*}
We can rewrite the multivariate linear regression model using matrices as:
\begin{align*}
\vy(\vx; \mW, \vb) = \mW^\top \vx + \vb = \mX_{\text{ext}} \mTheta,
\end{align*}
where \mTheta=[\mW⊤\vb.
Now, let's rewrite the objective function using matrices:
\begin{align*}
\sum_{n=1}^N \left|\vy(\vx_n; \mW, \vb) - \vt_n\right|2^2
&= \sum{n=1}^N \left|\mX_{\text{ext},n} \mTheta - \vt_n\right|2^2 \
&= \left|\mX{\text{ext}} \mTheta - \mY\right|_F^2,
\end{align*}
where \mXext,n is the n-th row of \mXext, and denotes the Frobenius norm.
To find the closed form solution, we need to minimize the objective function with respect to \mTheta. Setting the gradient of the objective function with respect to \mTheta to zero, we have:
\begin{align*}
\nabla_{\mTheta} \left(\left|\mX_{\text{ext}} \mTheta - \mY\right|_F^2\right) = 0.
\end{align*}
Expanding the squared Frobenius norm, we get:
\begin{align*}
\nabla_{\mTheta} \left(\mTheta^\top \mX_{\text{ext}}^\top \mX_{\text{ext}} \mTheta - 2 \mTheta^\top \mX_{\text{ext}}^\top \mY + \mY^\top \mY\right) = 0.
\end{align*}
Differentiating each term in the sum, we have:
\begin{align*}
2 \mX_{\text{ext}}^\top \mX_{\text{ext}} \mTheta - 2 \mX_{\text{ext}}^\top \mY &= 0.
\end{align*}
Simplifying, we get:
\begin{align*}
\mX_{\text{ext}}^\top \mX_{\text{ext}} \mTheta &= \mX_{\text{ext}}^\top \mY.
\end{align*}
Finally, we can find the closed form solution for \mTheta by solving this equation:
\begin{align*}
\mTheta^\star &= (\mX_{\text{ext}}^\top \mX_{\text{ext}})^{-1} \mX_{\text{ext}}^\top \mY.
\end{align*}
Since \mTheta=[\mW⊤\vb, we can extract and from to obtain the closed form solution for and .