Differentiating a sigmoid function using PyTorch

I tried to check the derivative manually but I got different answer , below I am attaching the code given in lecture and my solutionCapture

Given: r = \frac{1}{1+e^{-y}} where y = x + 5

Differentiating r(x),
\frac{dr}{dx} = \frac{dr}{dy} \frac{dy}{dx} = r (1-r) * 1

At x = 1, y = 6 and therefore
r = \frac{1}{1+e^{-6}} = 0.997527

Hence, \frac{dr}{dx} = 0.00246651 \approx 0.0025

2 Likes