文章目录
链式反向梯度传导
链式法则:
神经网络中的链式法则:
从loss向输入传播
每层导数(Δy,Δx)结果存储用于下一层导数的计算。
例如:
f(x,y,z) = (z+y)*z
分别求f对 x, y, z的偏导:
设q = x + y , 则f = qz ,因为q对x,y分别求偏导均为1,f对z,q求偏导为q,z,则f对x,y求偏导为q,z。
示例
f(x,y,w) = 1 / (e^- [(x1+x2)w + max(y1,y2)]^
得到的输入数据和结构如图:
一步步向前计算可得:
- x1+x2 = 1.5
- (x1+x2)w = 3
- max(y1,y2) = -2
- (x1+x2)w + max(y1,y2) = 1
- -(x1+x2)w + max(y1,y2) = -1
- e^-(x1+x2)w + max(y1,y2)^ = 0.368
- 则f(x,y,w) = 1 / (e^- [(x1+x2)w + max(y1,y2)]^ = 2.718
反向:
7,df/df = 1
6,f(x) = 1/x ; df/dx = -1/x2 ∴ 1 * (-1/0.3682) = - 7.39
5,f(x) = ex; df/dx = ex ∴ -7.39 * e-1 = -2.72
4,f(x) = -x; df/fx = -1 ∴ -2.72*(-1)= 2.72
3,f(x,y) = x+y; df/fx = 1, df/dy = 1 ∴ x = y = 2.72
2,f(x,y) = xy; df/dx = y,df/dy = x ∴ x = 2.722=5.44, y=w=2.721.5=4.08
1&#x