I was watching a public available video from Stanford (https://youtu.be/d14TUNcbn1k?t=2720) on the mathematics behind back propagation. They proposed a graph:

Graph 1

that was then used as an example of back propagation using matrices. (The red text is the back propagated gradient, the green is the forward pass vales). The final gradients found for the initial matrices (of $[[0.1,0.5],[-0.3,0.8]]$ and $[[0.2],[0.4]]$) is below: enter image description here

I agree with the values for $x$, however, I don't quite understand how they achieved the values of $W$. The equation (see circled in red) is the equation they used for calculating the gradients for $W$:enter image description here

With this equation (where $q$ = [[0.44],[0.52]], I would think that for $W_{1,2}$ (which has a value of 0.5, and $i$ = 1 and $j$ = 2) would be equal to $2*q_1*x_2$, which in this case is $2*0.22*0.4 = 0.176$, which is not what they got.

Intuitively, I thought the values of $W$ would be exactly what they calculated, but with $0.104$ and $0.176$ swapped. The way I calculated it was taking the top value of $q$ as the gradient on $0.22$ (which it is), and therefor, as $0.22 = 0.1*0.2 + 0.5*0.4$, taking $\frac{\partial q}{\partial W_{1,1}}=0.2$, and then multiplying this by $q_1$, I got $0.2*0.44=0.088$, which aligns with their calculations.

However, applying the same logic to $W_{1,2}$, I get $\frac{\partial q}{\partial W_{1,2}}=0.4$, and multiplying this by $q_1$, $0.4*0.44=0.176$. This conflicts with their value of $0.104$. If this logic is continued, the matrix of gradients matches theirs exactly, aside from the $0.104$ and $0.176$ being swapped.

For clarity, I also drew out a graph and deconstructed the matrix multiplication into simplified multiplication of two different regular equations. See below for the graph (where the numbers above nodes/inputs represent their gradient):

(Sorry for bad hand writing and quality, there's a reason I submit all work using latex)

I suspect I am using incorrect notation for $W$, as in, $W_{1,2}$ doesn't actually represent $0.5$, but actually $-0.3$, but then that doesn't align with their provided example of how the matrix $[[0.22],[0.26]]$ was constructed (the equation describing $q= W \cdot x = ...$), and also doesn't explain how I got the values for the graph I hand drew, as that doesn't rely on notation.

If you read all this and have any idea what I'm doing wrong I would very much appreciate your effort. Thankyou!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.