- First Question: Similar to homework
- Second Question: Basic idea, gradient calculation, maximum likelihood calculation
Given:
- Two classes
$C={c_{1},c_{2}}$ - A particular vector
$\mathbf{x}\in \mathbb{R}^d$ Do - Assign the vector
$\mathbf{x}$ to one of the two classes.- Namely, to calculate the probability of
$\mathbf{x}\in c_{i}$ for all$c_{i}\in C$ .
- Namely, to calculate the probability of
From the Bayesian Rule, we derive that $$ \begin{align} P(c_{1}|\mathbf{x})&=\frac{P(\mathbf{x}|c_1)P(c_1)}{P(\mathbf{x})} \ \ &=\frac{P(\mathbf{x}|c_1)P(c_1)}{P(\mathbf{x}|c_1)P(c_1)+P(\mathbf{x}|c_2)P(c_2)} \ \ &=\dfrac{1}{1+\frac{P(\mathbf{x}|c_{2})P(c_{{2}})}{P(\mathbf{x}|c{1})P(c_{1})}} \ \ &=\dfrac{1}{1+e^{-\ln\Bigl[\frac{P(\mathbf{x}|c_{1})}{P(\mathbf{x}|c_{2})}\Bigr]-\ln\Bigl[\frac{P(c_{1})}{P(c_{2})}\Bigr]}} \end{align} $$
which can be written in the form of a Logistic function / Sigmoid Function:
- Likelihood Ratio:
$\ln\Bigl[\frac{P(\mathbf{x}|c_{1})}{P(\mathbf{x}|c_{2})}\Bigr]$ - Prior Ratio:
$\ln\Bigl[\frac{P(c_{1})}{P(c_{2})}\Bigr]$
---
title: Logistic Function
xLabel: \xi
yLabel: \sigma
bounds: [-3, 3, -0.2, 1]
disableZoom: false
grid: true
---
f(x)=1/(1+E^(-x))
- [i] Limits $$ \begin{align} \lim_{ \xi \to -\infty }\sigma(\xi) &=0 \ \ \lim_{ \xi \to \infty }\sigma(\xi) &=1 \end{align} $$
- [i] Central Symmetry $$ \sigma(-\xi)=1-\sigma(\xi) $$
- [i] Derivative $$ \begin{align} \dfrac{d}{d\xi}\sigma(\xi) &= \sigma(\xi)(-\xi) \ &=\sigma(\xi)\Bigl(1-\sigma(\xi)\Bigr) \end{align} $$ Proof. $$ \begin{align} \dfrac{d}{d\xi}\sigma(\xi)&=\dfrac{d}{d\xi}\frac{1}{1+e^{-\xi}} \ \ &=(\dfrac{d}{d(1+e^{-\xi})}\cdot\frac{1}{1+e^{-\xi}})\cdot\frac{d(1+e^{-\xi})}{d\xi} \ \ &=\frac{-1}{(1+e^{-\xi})^2}\cdot(-e^{-\xi}) \ \ &=\frac{e^{-\xi}}{(1+e^{-\xi})^2} \ \ &=\frac{e^{-\xi}}{(1+e^{-\xi})}\cdot\frac{1}{(1+e^{-\xi})} \ \ &=\frac{1}{1+e^{\xi}}\cdot\frac{1}{1+e^{-\xi}} \ \ &=\sigma(-\xi)\cdot\sigma(\xi) \end{align} $$
Assumed that:
-
within each class
-
the multi-variate input vector
$\mathbf{x}$ follows a Gaussian Distribution with a common covariate$\Sigma$ . $$P(\mathbf{x}|c_{i})=\dfrac{1}{(2\pi)^\frac{d}{2}|\Sigma|^\frac{1}{2}}e^{-\frac{1}{2}(\mathbf{x}-\mathbf{\mu}{i})^\top\Sigma^{-1}(\mathbf{x}-\mathbf{\mu}{i})}$$ From which we derive that $$ \begin{align} \ln\Bigl(\frac{P(\mathbf{x}|c_1)}{P(\mathbf{x}|c_2)}\Bigr) &= \ln\Bigl[\frac{e^{-\frac{1}{2}(\mathbf{x}-\mu_1)^\top\Sigma^{-1}(\mathbf{x}-\mu_1)}}{e^{-\frac{1}{2}(\mathbf{x}-\mu_2)^\top\Sigma^{-1}(\mathbf{x}-\mu_2)}}\Bigr] \ \ &=\frac{1}{2}(\mathbf{x}-\mathbf{\mu}{2})^\top\Sigma^{-1}(\mathbf{x}-\mathbf{\mu}{2})-\frac{1}{2}(\mathbf{x}-\mathbf{\mu}{1})^\top\Sigma^{-1}(\mathbf{x}-\mathbf{\mu}{1}) \ \ &=\frac{1}{2}(\mathbf{x}^\top\Sigma^{-1}-\mathbf{\mu}{2}^\top\Sigma^{-1})(\mathbf{x}-\mathbf{\mu}{2})-\frac{1}{2}(\mathbf{x}^\top\Sigma^{-1}-\mathbf{\mu}{1}^\top\Sigma^{-1})(\mathbf{x}-\mathbf{\mu}{1}) \ \ &=\frac{1}{2}(\mathbf{x}^\top\Sigma^{-1}\mathbf{x}-\mathbf{x}^\top\Sigma^{-1}\mathbf{\mu}{2}-\mathbf{\mu}{2}^\top\Sigma^{-1}\mathbf{x}+\mathbf{\mu}{2}^\top\Sigma^{-1}\mathbf{\mu}{2}) \ &-\frac{1}{2}(\mathbf{x}^\top\Sigma^{-1}\mathbf{x}-\mathbf{x}^\top\Sigma^{-1}\mathbf{\mu}{1}-\mathbf{\mu}{1}^\top\Sigma^{-1}\mathbf{x}+\mathbf{\mu}{1}^\top\Sigma^{-1}\mathbf{\mu}{1}) \ \ &=\frac{1}{2}\Bigl[\mathbf{x}^\top\Sigma^{-1}(\mathbf{\mu}{1}-\mathbf{\mu}{2})+(\mathbf{\mu}{1}^\top-\mathbf{\mu}{2}^\top)\Sigma^{-1}\mathbf{x}+(\mathbf{\mu}{2}^\top+\mathbf{\mu}{1}^\top)\Sigma^{-1}(\mathbf{\mu}{2}-\mathbf{\mu}{1})\Bigr] \ \ &=(\mathbf{\mu}{1}-\mathbf{\mu}{2})^\top\Sigma^{-1}\mathbf{x}+\frac{1}{2}(\mathbf{\mu}{2}+\mathbf{\mu}{1})^\top\Sigma^{-1}(\mathbf{\mu}{2}-\mathbf{\mu}{1}) \end{align} $$ -
[*] Therefore, the exponential
$\xi$ can be rewritten as: $$ \begin{align} \xi &= \ln\Bigl(\frac{P(\mathbf{x}|c_1)}{P(\mathbf{x}|c_2)}\Bigr) + \ln\Bigl(\frac{P(c_1)}{P(c_2)}\Bigr) \ \ &= (\mathbf{\mu}{1}-\mathbf{\mu}{2})^\top\Sigma^{-1}\mathbf{x}+\frac{1}{2}(\mathbf{\mu}{2}+\mathbf{\mu}{1})^\top\Sigma^{-1}(\mathbf{\mu}{2}-\mathbf{\mu}{1})+\ln\Bigl(\frac{P(c_1)}{P(c_2)}\Bigr) \ \ &=\Bigl[\Sigma^{-1}(\mathbf{\mu}{1}-\mathbf{\mu}{2})\Bigr]^\top\mathbf{x} +\Bigl[\frac{1}{2}(\mathbf{\mu}{2}+\mathbf{\mu}{1})^\top\Sigma^{-1}(\mathbf{\mu}{2}-\mathbf{\mu}{1})+\ln\Bigl(\frac{P(c_{1})}{P(c_{2})}\Bigr)\Bigr]\ \ &=\mathbf{w}^\top\mathbf{x}+b \end{align} $$
In conclusion,
-
$\mathbf{w}=\Sigma^{-1}(\mu_{1}-\mu_{2})$ , and - $b=\frac{1}{2}(\mathbf{\mu}{2}+\mathbf{\mu}{1})^\top\Sigma^{-1}(\mathbf{\mu}{2}-\mathbf{\mu}{1})+\ln\Bigl[\frac{P(c_{1})}{P(c_{2})}\Bigr]$
Suppose that a variable
- i.e.,
$Y \sim \text{Bernoulli}(p)$ - where
$p$ is the probability of being$\text{Success}$ , the probabilistic distribution function is $$ P(Y=y)= \begin{cases} p & \text{if} \ y = 1 \ 1-p & \text{if} \ y=0 \end{cases} $$
We want to predict a binary output
Given ${(\mathbf{x}{n},y{n})|n=1,\dots,N}$, the likelihood is given by
$$
\begin{align}
P(\mathbf{y}|\mathbf{X},\mathbf{w}) &= \prod_{n=1}^{N}P(y_n|\mathbf{x}n) \ \
&=\prod{n=1}^{N}P\Bigl(y_n=1|\mathbf{x}n\Bigr)^{y_n}\cdot\Bigl(1-P(y_n=1|\mathbf{x}n)\Bigr)^{1-y_n} \ \
&=\prod{n=1}^{N}\sigma(\mathbf{w}^\top\mathbf{x}{n})^{y_{n}}\Bigl(1-\sigma(\mathbf{w}^\top\mathbf{x}{n})\Bigr)^{1-y{n}}
\end{align}
$$
The log-likelihood function is thus given by:
$$
\begin{align}
\mathcal{L}(\mathbf{y}|\mathbf{X},\mathbf{w}) &= \log\sum_{n=1}^{N}P(y_n|\mathbf{x}n) \ \
&= \sum{n=1}^{N}\Bigl(y_n\cdot\log\Bigl[\sigma(\mathbf{w}^\top\mathbf{x}_n)\Bigr]+(1-y_n)\cdot\log\Bigl[1-\sigma(\mathbf{w}^\top\mathbf{x})\Bigr]\Bigr)
\end{align}
$$
We want to maximize this log-likelihood
Consider a real-valued function
If
The Hessian matrix can not only help us find the extreme points of the function (through the first-order derivative is 0), but also determine whether the point is a minimum, maximum or saddle point by analyzing the curvature of the function near the extreme point. For example, if the Hessian matrix is positive definite, it means that the extreme point is a local minimum.
The gradient descent/ascent learning is a simple first-order iterative method for minimization/maximization.
Gradient Descent: Iterative Minimization
$$
\mathbf{w}^{(k+1)}=\mathbf{w}^{(k)}-\eta\Bigl(\frac{\partial \mathcal{J}}{\partial \mathbf{w}}\Bigr)
$$
Gradient Ascent: Iterative Maximization
$$
\mathbf{w}^{(k+1)}=\mathbf{w}^{(k)}+\eta\Bigl(\frac{\partial \mathcal{J}}{\partial \mathbf{w}}\Bigr)
$$
where the learning rate
The gradient
The Basic idea of Newton's method is to optimize the quadratic (二次的) approximation,
- of the objective function
$\mathcal{J}(\mathbf{w})$ , - around the current point
$\mathbf{w}^{(k)}$ .
The Newton's Method tells us that, for an arbitrary function $\mathcal{J}: \mathbb{R}^D\mapsto\mathbb{R}$ , we can iteratively approximate $\dfrac{\partial\mathcal{J}(\mathbf{w})}{\partial\mathbf{w}}=0$ by:
$$
\mathbf{w}^{\text{new}}
\Bigl[\nabla^2\mathcal{J}(\mathbf{w}^{\text{old}})\Bigr] \cdot \nabla\mathcal{J}(\mathbf{w}^{\text{old}}) $$
- [i] The objective of using Taylor Series of
$\mathcal{J}(\mathbf{w})$ is to: - Locally approximate the polynomial with Tayler Series at a specific step
$\mathbf{w}^{(k)}$ . The Taylor Series of a function$f(x): \mathbb{R}\mapsto\mathbb{R}$ around a point$a$ yields: $$ \begin{align} f(x) &= f(a)+\frac{f'(a)}{1!}(x-a) +\frac{f''(a)}{2!}(x-a)^2 +\frac{f'''(a)}{3!}(x-a)^3 +\cdots \ \ &= \sum_{i=0}^{\infty}\frac{f^{(i)}(a)}{i!}(x-a)^i \end{align} $$ Now we consider an abstract function$\mathcal{J}(\mathbf{w})$ . $$ \mathcal{J}:\mathbb{R}^D\mapsto\mathbb{R} $$ The second-order Taylor series expansion of$\mathcal{J}(\mathbf{w})$ at the current$\mathbf{w}^{(k)}$ gives:
$$ \mathcal{J}_{2}(\mathbf{w})= % First Term % \mathcal{J}(\mathbf{w}^{(k)}) + % Second Term % \begin{bmatrix} \nabla \mathcal{J}(\mathbf{w}^{(k)}) \end{bmatrix}^\top(\mathbf{w}-\mathbf{w}^{(k)}) + % Third Term % \frac{1}{2}(\mathbf{w}-\mathbf{w}^{(k)})^\top\Bigl\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\Bigr $$
Specifically:
- First term:
$\mathcal{J}(\mathbf{w}^{(k)})$ , is the value of the target function$\mathcal{J}$ with respect to the current$\mathbf{w}^{(k)}$ . - Second term:
$\nabla\mathcal{J}(\mathbf{w}^{(k)})$ is the gradient of the target function at the current$\mathbf{w}^{(k)}$ . - Third Term:
$\nabla^2\mathcal{J}(\mathbf{w}^{(k)})$ is the Hessian Matrix describing the target function's 2nd order derivative at current$\mathbf{w}^{(k)}$ .
Differentiate the above second-order Taylor Series with respect to $\mathbf{w}$ , we get the approximation of the gradient function at the point $\mathbf{w}$ :
$$
\nabla\mathcal{J}(\mathbf{w})=0+\nabla\mathcal{J}(\mathbf{w}^{(k)})
+\nabla^2\mathcal{J}(\mathbf{w}^{(k)})(\mathbf{w}-\mathbf{w}^{(k)})
$$
Remember that $\nabla\mathcal{J}(\mathbf{w})\in\mathbb{R}^d$ . Set the gradient equal to $\mathbb{0}^d$ :
$$
\begin{align}
&&\dfrac{\partial\mathcal{J}}{\partial\mathbf{w}} &= 0
\ \
&\implies \quad &
0 &= \nabla\mathcal{J}(\mathbf{w}^{(k)})
+
\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\cdot(\mathbf{w}-\mathbf{w}^{(k)})
\ \
&\implies \quad &
0 &=
\nabla\mathcal{J}(\mathbf{w}^{(k)})
+
\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\cdot\mathbf{w}-\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\cdot\mathbf{w}^{(k)}
\ \
&\implies \quad &
\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\mathbf{w} &= \nabla^2\mathcal{J}(\mathbf{w}^{(k)})\cdot\mathbf{w}^{(k)}
\Bigl[\nabla^2\mathcal{J}(\mathbf{w}^{(k)})\Bigr]^{-1} \cdot \nabla\mathcal{J}(\mathbf{w}^{(k)}) \end{align} $$
Note that the learning rate here is the inverse Hessian matrix.
At this point, we conclude that, for an arbitrary function
We can compute the optimal vector that produces the optimum scalar by:
- Calculate its gradient at the current step.
- Calculate its Hessian at current step.
- Apply Newton's method to get the vector of the next step.
- [I] Remark: We have already computed the log-likelihood
$\mathcal{L}(\mathbf{y}|\mathbf{X},\mathbf{w})$ under the given data set$\mathbf{X},\mathbf{y}$ .
Here,
- We need to find an optimal vector that produces the maximum scalar.
- But calculating
$\dfrac{\partial\mathcal{L}}{\partial\mathcal{w}}$ is very costly. - Therefore, we could have a work-around using Newton's method.
The gradient Ascent Learning has the form $$ \mathbf{w}^{\text{new}}=\mathbf{w}^{\text{old}}+\eta\Bigl(\dfrac{\partial\mathcal{L}}{\partial \mathbf{w}}\Bigr) $$
Recall the log-likelihood: $$ \mathcal{L}= \sum_{n=1}^{N}\Bigl[y_{n}\log \sigma(\mathbf{w}^\top\mathbf{x}{n}) + (1-y{n})\log\Bigl(1-\sigma(\mathbf{w}^\top\mathbf{x}{n})\Bigr)\Bigr] $$ Take its first order derivative as the gradient: $$ \dfrac{\partial\mathcal{L}}{\partial \mathbf{w}}=\sum{n=1}^{N}\Bigl[y_{n}\frac{\sigma_{n}'}{\sigma_{n}}\mathbf{x}{n}+(1-y{n})\frac{-\sigma_{n}'}{(1-\sigma_{n})}\mathbf{x}{n}\Bigr] $$ Note that using chain rule: $$ \begin{align} \dfrac{\partial}{\partial \mathbf{w}} \log\sigma(\mathbf{w}^\top\mathbf{x}{n}) &= \dfrac{\partial \mathcal{L}}{\partial\sigma} \cdot \dfrac{\partial\sigma}{\partial(\mathbf{w}^\top\mathbf{x}_n)} \cdot \dfrac{\partial\mathbf{w}^\top\mathbf{x}n}{\partial\mathbf{w}} \ \ &= \dfrac{1}{\sigma(\mathbf{w}^\top\mathbf{x}{n})} \cdot \sigma'(\mathbf{w}^\top\mathbf{x}_n) \cdot \mathbf{x}_n \end{align} $$
By using the 2nd and 3rd property of the logistic function
\sum_{n=1}^{N}\Bigl(y_{n}-\sigma(\mathbf{w}^\top\mathbf{x}{n})\Bigr)\mathbf{x}{n}
$$
As discussed before, it is a vector with the same shape of
- [*] By now we know that we could update
$\mathbf{w}$ by: $$ \mathbf{w}^{(k+1)} =\mathbf{w}^{(k)}+\eta \cdot \sum_{n=1}^{N}\Bigl[y_{n}-\sigma\Bigl(\mathbf{{w^{(k)}}^\top\mathbf{x}{n}}\Bigr)\Bigr]\mathbf{x}{n} $$
记到这里就行了,学习率老师会给所以海森矩阵不用手算。
Given:
- Historical data:
- $x_{1}=\begin{pmatrix}2\1\end{pmatrix}, x_{2}=\begin{pmatrix}1\2\end{pmatrix},x_{3}=\begin{pmatrix}3\3\end{pmatrix}$
$y_{1}=1,y_{2}=0,y_{3}=0$
- Probability:
-
$P(\mathbf{x}|\mathbf{x})=\sigma(\mathbf{w}^\top\mathbf{x})$ .
-
- Initial weight:
- $\mathbf{w}_{0}=\begin{bmatrix}0 \ 0\end{bmatrix}$.
- Learning rate:
-
$\eta=0.1$ Do:
-
- Update weight for one step. $$ \begin{align} \mathbf{w}{k+1}&=\mathbf{w}{k}+\eta \cdot \sum_{n}(y_{n}-\sigma(\mathbf{w}^\top\mathbf{x}{n}))\mathbf{x}{n} \ \ \mathbf{w}_{1} &=\begin{bmatrix}0\0\end{bmatrix}+0.1\cdot \Bigl[ (1-0.5)\begin{pmatrix}2\1\end{pmatrix}+(0-0.5)\begin{pmatrix}1\2\end{pmatrix}+(0-0.5)\begin{pmatrix}3\3\end{pmatrix} \Bigr]\ \ &= \begin{bmatrix}0\0\end{bmatrix}+0.1\cdot\begin{bmatrix}1-0.5-1.5\0.5-1-1.5\end{bmatrix}\ \ &= \begin{bmatrix}0\0\end{bmatrix}+0.1\cdot\begin{bmatrix}-1\-2\end{bmatrix}\ \ &= \begin{bmatrix}-0.1\-0.2\end{bmatrix} \end{align} $$
Calculate the Hessian: $$ \mathbf{H}=\nabla^2\mathcal{L} $$ Differentiate every term in the gradient: $$ \begin{align} \mathbf{H} &= \nabla^2\mathcal{L} \ \ &= \dfrac{\partial}{\partial\mathbf{w}}\Bigl[\sum_{n=1}^{N}(y_n-\sigma_n)\mathbf{x}n \Bigr]^\top \ \ &= \dfrac{\partial}{\partial\mathbf{w}}\sum{n=1}^{N}(y_n-\sigma_n)\mathbf{x}n^\top \ \ &= \sum{n=1}^{N}\dfrac{\partial}{\partial\mathbf{w}}(y_n-\sigma_n)\mathbf{x}n^\top \ \ &= \sum{n=1}^{N}-\sigma_n'\mathbf{x}n^\top \ \ &= \sum{n=1}^{N}-\sigma_n(1-\sigma_n)\mathbf{x}n\mathbf{x}n^\top \end{align} $$ In general: $$ \nabla^2\mathcal{L}=\sum{n=1}^{N}-\sigma{n}(1-\sigma_{n})\mathbf{x}{n}\mathbf{x}{n}^\top $$
Notice that the original Log-Likelihood:
$$\mathcal{L}(\mathbf{y}|\mathbf{X},\mathbf{w})=\log\sum_{n=1}^{n} P(y_{n}|\mathbf{x}{n})$$
is negative since the probability $P(y{n}|\mathbf{x}_{n})$ is lower than
Therefore, we set the objective function
- The gradient:
$\nabla\mathcal{J}(\mathbf{w})=-\sum_{n=1}^{N}(y_{n}-\sigma_{n})\mathbf{x}_{n}$ - The Hessian: $\nabla^2\mathcal{J}(\mathbf{w})=\sum_{n=1}^{N}\sigma_{n}(1-\sigma_{n})\mathbf{x}{n}\mathbf{x{n}}^\top$
The optimization problem went from:
- Maximizing
$\mathcal{L}$ - to minimizing
$-\mathcal{L}$
Therefore, we use gradient descent: $$ \mathbf{w}^{\text{new}} = \mathbf{w}^{\text{old}}-\eta\cdot\dfrac{\partial (-\mathcal{L})}{\partial\mathbf{w}} $$
The update part of the Newton's method $\eta\Bigl(\dfrac{\partial\mathcal{L}}{\partial \mathbf{w}}\Bigr)$ has the form:
$$
\Delta \mathbf{w}= - \Bigl[\sum_{n}^{N}\sigma_{n}(1-\sigma_{n})\mathbf{x}{n}\mathbf{x}{n}^\top\Bigr]^{-1}\Bigl[-\sum_{n=1}^{N}(y_{n}-\sigma_{n})\mathbf{x}_{n}\Bigr]
$$
Namely,
$$
\Delta \mathbf{w}
\Bigl( \mathbf{X} \ S \ \mathbf{X}^\top\Bigr)^{-1} Sb $$ where: $$ \begin{align} \ \ \mathbf{X} &= \begin{bmatrix}
- & \mathbf{x}_1^\top & - \
- & \mathbf{x}_2^\top & - \ & \vdots & \
- & \mathbf{x}d^\top & - \end{bmatrix} \ \ S &= \begin{bmatrix} \sigma{1}(1-\sigma_{1}) & 0 & \cdots & 0 \ 0 & \sigma_{2}(1-\sigma_{2}) & \cdots & 0 \ \vdots & \vdots & \ddots & 0 \ 0 & 0 & \cdots & \sigma_{n}(1-\sigma_{n}) \end{bmatrix} \ \ b &= \begin{bmatrix}\frac{y_{1}-\sigma_{1}}{\sigma_{1}(1-\sigma_{1})}\\frac{y_{2}-\sigma_{2}}{\sigma_{2}(1-\sigma_{2})}\\vdots\\frac{y_{N}-\sigma_{N}}{\sigma_{N}(1-\sigma_{N})}\end{bmatrix} \end{align} $$
Input
- ${(\mathbf{x}{n}, y{n})|n=1,2,\cdots,N}$ Do
- Initialize
$\mathbf{w}=0$ and$w_{0}=\log\frac{\bar{\mathbf{y}}}{1-\bar{\mathbf{y}}}$ - Repeat until convergence:
- for
$n=1,2,\cdots,N$ do:- Compute $\sigma_{n}=\sigma(\mathbf{w}^\top\mathbf{x}{n}+w{0})$
- Compute
$s_{n}=\sigma_{n}(1-\sigma_{n})$ - Compute
$b_{n}=\frac{y_{n}-\sigma_{n}}{s_{n}}$
- Construct
$S=diag(s_{1:N})$ - Update
$\mathbf{w}=(XSX^\top)Sb$ Output
- for
$\mathbf{w}$
In the multi-class classification essence, we will give each class its own weight. Suppose that we have
....
Given historical data as below. If current weights
| index | |||
|---|---|---|---|
| 1 | 2 | 1 | 1 |
| 0 | 1 | 2 | 2 |
| 0 | 3 | 3 | 3 |
\mathbf{w}^{(k)} + \eta \cdot \sum_{n=1}^{3}\Bigl[y_{n}-\sigma\Bigl((\mathbf{w}^{(k)})^\top\mathbf{x}{n}\Bigr)\Bigr]\mathbf{x}{n} $$ Summation term: $$ \mathbf{w}_{1}=0.1\times\Bigl[\Bigl(1-\sigma(0)\Bigr)\begin{bmatrix}2\1\end{bmatrix}+\Bigl(0-\sigma(0)\Bigr)\begin{bmatrix}1\2\end{bmatrix}+\Bigl(0-\sigma(0)\Bigr)\begin{bmatrix}3\3\end{bmatrix}\Bigr] $$ $$ =0.1\times\Bigl[\frac{1}{2}\begin{bmatrix}2\1\end{bmatrix}-\frac{1}{2}\begin{bmatrix}1\2\end{bmatrix}-\frac{1}{2}\begin{bmatrix}3\3\end{bmatrix}\Bigr] $$ $$ =0.1\times\begin{bmatrix} 1-\frac{1}{2}-\frac{3}{2} \ \frac{1}{2}-1-\frac{3}{2} \end{bmatrix} $$