简单理解ConvNet层的Backpropagation

这里只谈一下二维的情况,也就是channel = 1, strides = 1的情况下,单就这一层的计算.

ConvNet forward propagation

filter’s shape: [height, length, 1]
CNN forward

y i , j = Σ n = 0 l e n g t h Σ m = 0 h e i g h t W m , n x i + m , j + n y_{i,j} = \Sigma_{n=0}^{length}\Sigma_{m=0}^{height} W_{m,n}x_{i+m,j+n} yi,j=Σn=0lengthΣm=0heightWm,nxi+m,j+n

ConvNet backpropagation

对于该层,我们首先已知 ∂ L ∂ y i , j \frac{\partial{L}}{\partial y_{i,j}} yi,jL, 我们将他重新命名为 δ y i , j \delta{y_{i,j}} δyi,j
首先用全微分用 W , x W, x W,x来表达 d y i , j dy_{i,j} dyi,j:
d y i , j = Σ n = 0 l e n g t h Σ m = 0 h e i g h t d W m , n x i + m , j + n + Σ n = 0 l e n g t h Σ m = 0 h e i g h t W m , n d x i + m , j + n dy_{i,j} = \Sigma_{n=0}^{length}\Sigma_{m=0}^{height} dW_{m,n}x_{i+m,j+n} + \Sigma_{n=0}^{length}\Sigma_{m=0}^{height} W_{m,n}dx_{i+m,j+n} dyi,j=Σn=0lengthΣm=0heightdWm,nxi+m,j+n+Σn=0lengthΣm=0heightWm,ndxi+m,j+n
从上式我们可以看出:
∂ y i , j ∂ x i + m , j + n = W m , n \frac{\partial y_{i,j}}{\partial x_{i+m,j+n}} = W_{m,n} xi+m,j+nyi,j=Wm,n
而通过链式法则
∂ L ∂ x i , j = Σ h , k ∂ y i − h , j − k ∂ x i , j ∂ L ∂ y i − h , j − k = Σ h , k W h , k ∂ L ∂ y i − h , j − k \frac{\partial{L}}{\partial x_{i,j}} = \Sigma_{h,k} \frac{\partial y_{i-h,j-k}}{\partial x_{i,j}}\frac{\partial{L}}{\partial y_{i-h,j-k}} = \Sigma_{h,k} W_{h,k} \frac{\partial{L}}{\partial y_{i-h,j-k}} xi,jL=Σh,kxi,jyih,jkyih,jkL=Σh,kWh,kyih,jkL
这个等式告诉我们,其实ConvNet的Backpropagation其实也是一个ConvNet,不过需要做一定的padding, padding的量为[height, width], 这个结果应该就是很多代码中的element-wise operation。
Question: 如果 strides != 1呢?
Answer(我也不知道对不对): if strides.shape = (stride1, stride2)个人认为解决方法可以是对输出矩阵Y各元素之间加上(stride1-1, stride2-1)个0
另外还有 ∂ L ∂ W i , j \frac{\partial{L}}{\partial W_{i,j}} Wi,jL
∂ L ∂ W i , j = Σ h , k ∂ y i − h , j − k ∂ W i , j ∂ L ∂ y i − h , j − k = Σ h , k x h , k ∂ L ∂ y i − h , j − k \frac{\partial{L}}{\partial W_{i,j}} = \Sigma_{h,k} \frac{\partial y_{i-h,j-k}}{\partial W_{i,j}}\frac{\partial{L}}{\partial y_{i-h,j-k}} = \Sigma_{h,k} x_{h,k} \frac{\partial{L}}{\partial y_{i-h,j-k}} Wi,jL=Σh,kWi,jyih,jkyih,jkL=Σh,kxh,kyih,jkL

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值