We will only be calculating the derivative of the hidden layer in this case. We compute our hidden layer by passing the input data through the sigmoid function → hidden_layer = sigmoid(input_data). The hidden layer is the output of the sigmoid function and can, therefore, be represented as S(x) with “x” being the input data.

When we define our sigmoid function, we write def sigmoid(x, deriv=False), where the “x” is a parameter that takes on whichever value we give it when we call the function.

When we calculate the hidden layer’s derivative, we are passing the hidden layer as the value for the “x” parameter and so x * (1 — x) becomes hidden_layer * (1 — hidden_layer) or S(x) * (1 — S(x)).

I hope this helps!

Data Science and Economics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store