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

Data Science and Economics