CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结

计算图

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结

反向传播

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
   同理对于x与z来说同样使用链式法则就可以求出所需要的导数,这就是反向传播求导的由来,这里的倒数就是调整ω参数的缘由。

求导在神经元中的显示

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结

  这里就完全展示了通过其中神经元f函数后反向求导时的过程,另外在加入了非线性函数后一样可以通过这里的导数来求解。

另一个复杂一点的例子(BackPropagation)

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
第二步
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
一直持续这个过程直到节点位置
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
+(加法)节点将梯度分开且并不改变梯度大小
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
最终计算到最后的节点梯度

sigmoid函数

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
这里的额反向传播过程和上面的一样,将其中几个节点计算过程合并,其实就是sigmoid函数的反向传播过程即加入非线性函数。

Backward flow的gate的作用

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
这里可以看到
ADD gate仅仅起到的是梯度的分散作用
MAX gate可以起到梯度的引导作用
MUL gate可以起到梯度相乘选择的作用

这里是向量的矩阵表示

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
其中的Jacobian矩阵为下列矩阵
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
根据Jacobian矩阵的矩阵表示可以看出Jacobian矩阵的维度如下所示
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
in practice we process an entire minibatch (e.g. 100) of examples at one time
i.e. Jacobian would technically be a [409,600 x 409,600] matrix

梯度的矩阵求法

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
由图片可知基本和元素的反向传播没有区别,只是加入了矩阵运算

编程实现反向传播的API

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
其中定义forward块与backward块即可。

  • 以一个Multiple gate为例子:
    CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
    首先定义前向传播过程(这个是比较好定义的)
    CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
    再通过求导之后可以得到反向传播的过程

Neural Network

除去神经元表示法的矩阵表示
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结
利用20行代码表示2层的神经网络
CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结

一些**函数

CS231n 2017Spring Lecture4 Backpropagation and Neural Networks 总结

The End