# Perceptron update rule demonstration

## Perceptron

Let’s consider the following simple perceptron:

## Transfert function

The transfert function is given by:

$y= f(w_1.x_1 + w_2.x_2 + ... + w_N.x_N) = f(\sum\limits_{i=1}^N w_i.x_i)$

Let’s define the sum $S(w_i,x_i)$:

$S(w_i,x_i)= \sum\limits_{i=1}^N w_i.x_i)$

Let’s rewrite $y$:

$y= f(\sum\limits_{i=1}^N w_i.x_i)=f(S(w_i,x_i))$

## Error (or loss)

In artificial neural networks, the error we want to minimize is:

$E=(y$

with:

• $E$ the error
• $y$ the expected output (from training data set)
• $y$ the real output of the network (from network)

In practice and to simplify the maths, this error is divided by two:

$E=\frac{1}{2}(y$

The algorithm (gradient descent) used to train the network (i.e. updating the weights) is given by:

$w_i$

where:

• $w_i$ the weight before update
• $w_i$ the weight after update
• $\eta$ the learning rate

## Derivating the error

Let’s derivate the error:

$\frac{dE}{dw_i} = \frac{1}{2}\frac{d}{dw_i}(y$

Thanks to the chain rule [ $(f \circ g)$ ] the previous equation can be rewritten:

$\frac{dE}{dw_i} = \frac{2}{2}(y$

Let’s calculate the derivative of $y$:

$\frac{dy}{dw_i} = \frac{df(S(w_i,x_i))}{dw_i}$

Thanks to the chain rule [ $(f \circ g)$ ] the previous equation can be rewritten:

$\frac{df(S)}{dw_i} = \frac{df(S)}{dS}\frac{dS}{dw_i} = x_i\frac{df(S)}{dS}$

The derivative of the error becomes:

$\frac{dE}{dw_i} = -x_i(y$

## Updating the weights

The weights can be updated with the following formula:

$w_i$

In conclusion :

$w_i$