2
$\begingroup$

I'm currently using 3Blue1Brown's tutorial series on neural networks and lack extensive calculus knowledge/experience.

I'm using the following equations to calculate the gradients for weights and biases as well as the equations to find the derivative of the cost with respect to a hidden layer neuron:

EQUATIONS

The issue is, during backpropagation, the gradients keep cancelling each other out because I take an average for opposing training examples. That is, if I have two training labels being [1, 0], [0, 1], the gradients that adjust for the first label get reversed by the second label because an average for the gradients is taken. The network simply keeps outputting the average of these two and causes the network to always output [0.5, 0.5], regardless of the input.

To prevent this, I figured a softmax function would be required for the last layer instead of a sigmoid, which I used for all the layers.

However, I have no idea how to implement this. The math is difficult to understand and the notation is complicated for me.

The equations I provided above show the term: σ'(z), which is the derivative of the sigmoid function.

If I'm using softmax, how am I supposed to substitute sigmoid with it?

If I'm not mistaken, the softmax function doesn't just take one number analogous to the sigmoid, and uses all the outputs and labels.

To sum it up, the things I'd like to know and understand are:

  1. The equation for the neuron in every layer besides the output is: σ(w1x1 + w2x2 + ... + wnxn + b). How am I supposed to make an analogous equation with softmax for the output layer?
  2. After using (1) for forward propagation, how am I supposed to replace the σ'(z) term in the equations above with something analogous to softmax to calculate the partial derivative of the cost with respect to the weights, biases, and hidden layers?
$\endgroup$
1
  • $\begingroup$ Welcome to AI! (Thanks for posting the graphic--some of the characters are a little hard to read, but zooming in on the image solves it. Still, may want to bold the hard to read characters.) $\endgroup$
    – DukeZhou
    Commented May 10, 2018 at 21:36

1 Answer 1

2
$\begingroup$

One of the best ways to learn is use reference of others.

Have a look at Peter Sadowski - Notes on Backpropagation (Page 3):

enter image description here

There is also a great blog post by Eli Bendersky - The Softmax Function and Its Derivative.

$\endgroup$

You must log in to answer this question.