Partial derivative of the logistic function

3.1k Views Asked by At

I'm trying to compute the partial derivative of the logistic function with respect to one parameter. I computed it but I just need someone to confirm my calculations.

Definitions: Suppose we have a parameter vector $w = [ w_1, w_2]$ and a feature vector $x = [x_1, x_2] $.

The logistic function: $f(w.x) = \frac{1}{1+e^{-w.x}}$.

I need to compute the partial derivative of $f$ with respect to $w_1$ for example. Here is my calculations:

$\frac{\partial f}{w_1} = \frac{x_1 . e^{-w.x}}{(1+e^{-w.x})^2}$

$\frac{\partial f}{w_2} = \frac{x_2 . e^{-w.x}}{(1+e^{-w.x})^2}$

So is my calculation correct for the partial derivatives?

2

There are 2 best solutions below

0
On BEST ANSWER

Yes, that is correct. You even have the sign right.

1
On

I can see that you want to derivate the logistic function respect to w (I will supposed that w is for weights and you want to derivate that function to train a neural network)

To derivate f(x) where f(x) is a logistic function: f'(x) = f(x)(1-f(x))

This is why:

1- f(x) = (1+e^-x)^-1 2- f'(x) = (1+e^-x)^-2 * e^-x

3.- f(x) = 1/1+e^-x -> 1+e^-x = 1/f(x) -> 4- e^-x = (1/f(x)) -1 5.- f(x)^2 = 1/(1+e^-x)^2 6.--> f(x)^2 = (1+e^-x)^-2

de 2 sustituimos 4 y 6

f'(x) = (1+e^-x)^-2 * e^-x f'(x) = f(x)^2 * (1/f(x)) -1 f'(x) = f(x)^2/f(x) - f(x)^2 f'(x) = f(x) - f(x)^2 f'(x) = f(x)(1-f(x))