Skip to content

Commit d952361

Browse files
Merge pull request #109 from waspinator/master
Updated optimization-2
2 parents 2be41f9 + 220e860 commit d952361

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

optimization-2.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ f = q * z # f becomes -12
8282
# first backprop through f = q * z
8383
dfdz = q # df/dz = q, so gradient on z becomes 3
8484
dfdq = z # df/dq = z, so gradient on q becomes -4
85+
dqdx = 1.0
86+
dqdy = 1.0
8587
# now backprop through q = x + y
86-
dfdx = 1.0 * dfdq # dq/dx = 1. And the multiplication here is the chain rule!
87-
dfdy = 1.0 * dfdq # dq/dy = 1
88+
dfdx = dfdq * dqdx # The multiplication here is the chain rule!
89+
dfdy = dfdq * dqdy
8890
```
8991

9092
We are left with the gradient in the variables `[dfdx,dfdy,dfdz]`, which tell us the sensitivity of the variables `x,y,z` on `f`!. This is the simplest example of backpropagation. Going forward, we will use a more concise notation that omits the `df` prefix. For example, we will simply write `dq` instead of `dfdq`, and always assume that the gradient is computed on the final output.

0 commit comments

Comments
 (0)