上一节介绍了卷积的基本思想以及图像卷积操作,本节将介绍卷积神经网络,并从反向传播角度认识卷积神经网络。
基于图像卷积的一次卷积过程可描述为:
基于某像素点周围像素点的影响,构建相应大小的卷积核 ( Convolution Kernel ) (\text{Convolution Kernel}) (Convolution Kernel);卷积核与被卷积核覆盖的像素点做卷积并最终生成一个像素点。
以某像素点周围一圈的像素点为例,也就是 3 × 3 3 \times 3 3×3大小卷积核,这个生成过程可表示为:
从图中明显看出,新像素值 ( New Pixel Value ) (\text{New Pixel Value}) (New Pixel Value)可看作是由源像素点 ( Souce Pixel ) (\text{Souce Pixel}) (Souce Pixel)与其周围像素点的一次卷积产生的更新结果。
下图描述某图像局域像素点的表示。其中 ( x , y ) (x,y) (x,y)表示横纵坐标,用来描述像素点在某图像中唯一确定的位置;而 f ( x , y ) f(x,y) f(x,y)表示该位置像素点的颜色信息,它有可能是一个基于 3 3 3通道的向量(描述彩色的颜色信息),也可能是一个单通道的向量(描述黑白的颜色信息),但这并不是重点。
同理, f ( x − 1 , y + 1 ) , f ( x , y + 1 ) , ⋯ f(x-1,y+1),f(x,y+1),\cdots f(x−1,y+1),f(x,y+1),⋯描述像素点 ( x , y ) (x,y) (x,y)周围像素点的颜色信息。而红色箭头表示像素点 ( x , y ) (x,y) (x,y)被卷积操作后的加权过程。
既然是执行卷积操作,那么就必然有卷积函数。根据卷积的定义:
这里是指‘包含两个离散型随机变量’的卷积过程。
h ( x , y ) = ∑ f ( x , y ) ⋅ g ( m − x , n − y ) = f ( x , y ) ∗ g ( m , n ) \begin{aligned} h(x,y) & = \sum f(x,y) \cdot g(m - x,n-y) \\ & = f(x,y) * g(m,n) \end{aligned} h(x,y)=∑f(x,y)⋅g(m−x,n−y)=f(x,y)∗g(m,n)
在各维度在不同位置 ( m , n ) (m,n) (m,n)下,对应位置的卷积函数 g ( m , n ) g(m,n) g(m,n)可表示为:
以像素点
f ( x − 1 , y + 1 ) f(x-1,y+1) f(x−1,y+1)为例。它的位置可表示为
( x − 1 , y + 1 ) (x-1,y+1) (x−1,y+1),该位置与中心点
f ( x , y ) f(x,y) f(x,y)之间的相对位置表示为
( x − 1 − x , y + 1 − y ) ⇒ ( − 1 , 1 ) ⇒ g ( − 1 , 1 ) (x-1-x,y+1-y) \Rightarrow(-1,1) \Rightarrow g(-1,1) (x−1−x,y+1−y)⇒(−1,1)⇒g(−1,1),以此类推。
但在执行卷积的过程中,各像素点是如何执行的 ? ? ?依然以 f ( x − 1 , y + 1 ) f(x-1,y+1) f(x−1,y+1)为例。由于需要将 f ( x − 1 , y + 1 ) f(x-1,y+1) f(x−1,y+1)加权到核心像素点 f ( x , y ) f(x,y) f(x,y)上,因此该点对应的权重 g g g应该是:
注意方向。当前状态是
f ( x − 1 , y + 1 ) f(x-1,y+1) f(x−1,y+1),目标状态是
f ( x , y ) f(x,y) f(x,y)。
g [ x − ( x − 1 ) , y − ( y + 1 ) ] = g ( 1 , − 1 ) g[x - (x-1),y-(y+1)] = g(1,-1) g[x−(x−1),y−(y+1)]=g(1,−1)
可以发现,这个 g ( 1 , − 1 ) g(1,-1) g(1,−1)的位置与f(x-1,y+1)关于中心点对称。而图像卷积操作是对应位置相乘再相加。因此,真正的卷积核应该是如下格式:
可以发现,卷积核并不是卷积函数,而是将卷积函数按照中心点旋转 180 180 180度的对应结果。
但是我们平常都是直接使用’卷积核‘执行计算,实际上中间还有一步卷积函数,只不过省略掉了。
总结:图像卷积运算本质是周围像素点对中心像素点产生影响(有顺序),而 g g g函数针对如何影响中心像素点做出了规定。
在上一节,以平滑操作为例,描述了卷积核的一种表达。旨在对目标图像进行模糊处理(均值滤波):
后续卷积操作这里仅描述卷积核核对应效果,函数不修改。
import numpy as np
import cv2
def FilterOperation(Kernel):
Img = cv2.imread(r'C:\Users\Administrator\Desktop/PicSample.jpg',cv2.IMREAD_GRAYSCALE)
FilterOut = cv2.filter2D(Img, -1, kernel=Kernel)
htich = np.hstack((Img, FilterOut))
cv2.imshow("merged_img", htich)
cv2.waitKey(0)
if __name__ == '__main__':
Kernel = np.array([
[1/9, 1/9, 1/9],
[1/9, 1/9, 1/9],
[1/9, 1/9, 1/9]],
dtype=np.float32)
FilterOperation(Kernel)
对比效果图如下:
左侧为正常图像,右侧为卷积后效果,下同。
再例如锐化操作,使图片看起来更加有立体感。
Kernel = np.array([
[0, -1, 0],
[-1, 5, -1],
[0, -1, 0]],
dtype=np.float32)
对比效果图如下:
不可否认的是,我们确实能够通过调整卷积核的格式得到我们想要的效果。它们本质上依然是:周围像素点对中心像素点产生的影响。
但卷积神经网络是通过滤波器卷积的方式对图片的特征进行描述,那么卷积是如何描述/提取特征的呢 ? ? ?
介绍一个滤波器汇总的文章。文章见下方链接,侵删。
例如:垂直边界过滤器 ( Vertical Filter ) (\text{Vertical Filter}) (Vertical Filter):
Kernel = np.array([
[1, 0, -1],
[1, 0, -1],
[1, 0, -1]],
dtype=np.float32)
对比效果如下:
很明显,我们能够很容易地通过卷积后的图片中观测到物品的垂直方向的边界特征。而其他的特征信息被过滤掉。因而这种卷积核也被称作过滤器 ( Filter ) (\text{Filter}) (Filter)。
虽然也是在做卷积操作,但这种核能够将图片中的信息’挑‘出来。
同理,还有横向边界过滤器 ( Horizontal Filter ) (\text{Horizontal Filter}) (Horizontal Filter):
Kernel = np.array([
[1, 1, 1],
[0, 0, 0],
[-1, -1, -1]],
dtype=np.float32)
对比效果如下:
通过上面的描述,可以观察到卷积的一种功能:如果挑选的卷积核合适,那么对图片的卷积过程中就可以对图片进行过滤。而这个过滤的目的是将图片中的某些特征保留下来,而其他的特征就被过滤掉了。
由于卷积就是通过周围像素点对中心像素点的一种加权描述,因而如果从权重的角度观察:
而如何去对关注进行分配——如何对分配关注度,从而基于关注度对卷积核元素进行调整,自然是神经网络对卷积核中元素的参数更新的结果。
那么卷积神经网络是如何实现反向传播过程呢 ? ? ?在反向传播算法一节中介绍过常规的全连接神经网络它的反向传播过程。它的特点是:网络中的每一个神经元,其神经元内的每个输入均包含一个权重信息与其映射:
但卷积神经网络的特点在于:卷积层在执行卷积的过程中,对于输入的任意一个像素点,在卷积核的视角中都是一视同仁的。也就是说,在某次迭代过程中,某卷积层内的前馈计算,所有像素点(层输入特征)均公用同一个卷积核。
那么通过卷积层得到的输出结果,每一个分量都能够更新梯度,但是卷积核就那么大,它是如何获取输出结果所有分量的梯度的 ? ? ?
这里我们仅选择通道数 C = 1 \mathcal C = 1 C=1的灰度图像作为示例。已知一个 3 × 3 3 \times 3 3×3大小的灰度图像,它的矩阵格式表示如下:
X = ( x 11 , x 12 , x 13 x 21 , x 22 , x 23 x 31 , x 32 , x 33 ) \mathcal X = \begin{pmatrix} x_{11},x_{12},x_{13} \\ x_{21},x_{22},x_{23} \\ x_{31},x_{32},x_{33} \end{pmatrix} X= x11,x12,x13x21,x22,x23x31,x32,x33
构建一个 2 × 2 2 \times 2 2×2大小的卷积核,其矩阵格式表示如下:
F = ( f 11 , f 12 f 21 , f 22 ) \mathcal F = \begin{pmatrix} f_{11},f_{12} \\ f_{21},f_{22} \end{pmatrix} F=(f11,f12f21,f22)
使用卷积核 F \mathcal F F对 X \mathcal X X执行卷积操作。设其卷积结果为 O \mathcal O O。假设卷积过程中,其步长 ( Stride ) = 1 (\text{Stride}) = 1 (Stride)=1,并且不添加 0 0 0填充 ( Padding=0 ) (\text{Padding=0}) (Padding=0)。那么其卷积结果 O \mathcal O O应该是一个 2 × 2 2 \times 2 2×2的矩阵格式:
O = ( o 11 , o 12 o 21 , o 22 ) \mathcal O = \begin{pmatrix} o_{11},o_{12} \\ o_{21},o_{22} \end{pmatrix} O=(o11,o12o21,o22)
对应的输出结果 o o o可表示为:
{ o 11 = x 11 ⋅ f 11 + x 12 ⋅ f 12 + x 21 ⋅ f 21 + x 22 ⋅ f 22 o 12 = x 12 ⋅ f 11 + x 13 ⋅ f 12 + x 22 ⋅ f 21 + x 23 ⋅ f 22 o 21 = x 21 ⋅ f 11 + x 22 ⋅ f 12 + x 31 ⋅ f 21 + x 32 ⋅ f 22 o 22 = x 22 ⋅ f 11 + x 23 ⋅ f 12 + x 32 ⋅ f 21 + x 33 ⋅ f 22 \begin{cases} o_{11} = x_{11} \cdot f_{11} + x_{12} \cdot f_{12} + x_{21} \cdot f_{21} + x_{22} \cdot f_{22} \\ o_{12} = x_{12} \cdot f_{11} + x_{13} \cdot f_{12} + x_{22} \cdot f_{21} + x_{23} \cdot f_{22} \\ o_{21} = x_{21} \cdot f_{11} + x_{22} \cdot f_{12} + x_{31} \cdot f_{21} + x_{32} \cdot f_{22} \\ o_{22} = x_{22} \cdot f_{11} + x_{23} \cdot f_{12} + x_{32} \cdot f_{21} + x_{33} \cdot f_{22} \end{cases} ⎩ ⎨ ⎧o11=x11⋅f11+x12⋅f12+x21⋅f21+x22⋅f22o12=x12⋅f11+x13⋅f12+x22⋅f21+x23⋅f22o21=x21⋅f11+x22⋅f12+x31⋅f21+x32⋅f22o22=x22⋅f11+x23⋅f12+x32⋅f21+x33⋅f22
这里暂时不考虑池化以及其他全连接层,仅考虑该卷积层一项的反向传播操作。
假设该任务的损失函数为 L \mathcal L L,并且已知 L \mathcal L L关于输出矩阵 O \mathcal O O的梯度信息 ∂ L ∂ O \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal O}\end{aligned} ∂O∂L:
∂ L ∂ O = ( ∂ L ∂ o 11 , ∂ L ∂ o 12 ∂ L ∂ o 21 , ∂ L ∂ o 22 ) \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal O} = \begin{pmatrix} \begin{aligned} \frac{\partial \mathcal L}{\partial o_{11}},\frac{\partial \mathcal L}{\partial o_{12}} \\ \frac{\partial \mathcal L}{\partial o_{21}},\frac{\partial \mathcal L}{\partial o_{22}} \end{aligned} \end{pmatrix}\end{aligned} ∂O∂L= ∂o11∂L,∂o12∂L∂o21∂L,∂o22∂L
假设使用的方法是梯度下降法 ( Gradient Descent,GD ) (\text{Gradient Descent,GD}) (Gradient Descent,GD),那么卷积核 F \mathcal F F内参数的更新过程可表示为:
F update ⇐ F − η ⋅ ∂ L ∂ F \mathcal F_{\text{update}} \Leftarrow \mathcal F - \eta \cdot \frac{\partial \mathcal L}{\partial \mathcal F} Fupdate⇐F−η⋅∂F∂L
依然使用链式求导法则对 ∂ L ∂ F \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal F}\end{aligned} ∂F∂L进行求解:
∂ L ∂ F = ∂ L ∂ O ⋅ ∂ O ∂ F \begin{aligned} \frac{\partial \mathcal L}{\partial \mathcal F} = \frac{\partial \mathcal L}{\partial \mathcal O} \cdot \frac{\partial \mathcal O}{\partial \mathcal F} \end{aligned} ∂F∂L=∂O∂L⋅∂F∂O
这里以 ∂ L ∂ f 11 \begin{aligned}\frac{\partial \mathcal L}{\partial f_{11}}\end{aligned} ∂f11∂L为例。观察:哪些输出结果中用到了 f 11 f_{11} f11——都用到了。因此, ∂ L ∂ f 11 \begin{aligned}\frac{\partial \mathcal L}{\partial f_{11}}\end{aligned} ∂f11∂L可表示为:
这里所说的’都用到了‘是必然的,无论多大的输入数据,只要使用这种方式执行卷积,所有被卷积的像素点都会被
F \mathcal F F计算。
∂ L ∂ f 11 = ∂ L ∂ o 11 ⋅ ∂ o 11 ∂ f 11 + ∂ L ∂ o 12 ⋅ ∂ o 12 ∂ f 11 + ∂ L ∂ o 21 ⋅ ∂ o 21 ∂ f 11 + ∂ L ∂ o 22 ⋅ ∂ o 22 ∂ f 11 \begin{aligned} \frac{\partial \mathcal L}{\partial f_{11}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot \frac{\partial o_{11}}{\partial f_{11}} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot \frac{\partial o_{12}}{\partial f_{11}} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot \frac{\partial o_{21}}{\partial f_{11}} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot \frac{\partial o_{22}}{\partial f_{11}} \end{aligned} ∂f11∂L=∂o11∂L⋅∂f11∂o11+∂o12∂L⋅∂f11∂o12+∂o21∂L⋅∂f11∂o21+∂o22∂L⋅∂f11∂o22
其中 ∂ L ∂ o ′ ( o ′ = o 11 , o 12 , o 21 , o 22 ) \begin{aligned}\frac{\partial \mathcal L}{\partial o'}(o'=o_{11},o_{12},o_{21},o_{22})\end{aligned} ∂o′∂L(o′=o11,o12,o21,o22)都是已知项,以 ∂ o 11 ∂ f 11 \begin{aligned}\frac{\partial o_{11}}{\partial f_{11}}\end{aligned} ∂f11∂o11为例,它的解可表示为:
其他项同理,这里就不展开了。
∂ o 11 ∂ f 11 = x 11 \frac{\partial o_{11}}{\partial f_{11}} = x_{11} ∂f11∂o11=x11
至此, ∂ L ∂ f 11 \begin{aligned}\frac{\partial \mathcal L}{\partial f_{11}}\end{aligned} ∂f11∂L表示为:
∂ L ∂ f 11 = ∂ L ∂ o 11 ⋅ x 11 + ∂ L ∂ o 12 ⋅ x 12 + ∂ L ∂ o 21 ⋅ x 21 + ∂ L ∂ o 22 ⋅ x 22 \frac{\partial \mathcal L}{\partial f_{11}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot x_{11} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot x_{12} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot x_{21} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot x_{22} ∂f11∂L=∂o11∂L⋅x11+∂o12∂L⋅x12+∂o21∂L⋅x21+∂o22∂L⋅x22
同理,其他三个参数: f 12 , f 21 , f 22 f_{12},f_{21},f_{22} f12,f21,f22的偏导表示为如下形式:
{ ∂ L ∂ f 12 = ∂ L ∂ o 11 ⋅ ∂ o 11 ∂ f 12 + ∂ L ∂ o 12 ⋅ ∂ o 12 ∂ f 12 + ∂ L ∂ o 21 ⋅ ∂ o 21 ∂ f 12 + ∂ L ∂ o 22 ⋅ ∂ o 22 ∂ f 12 ∂ L ∂ f 21 = ∂ L ∂ o 11 ⋅ ∂ o 11 ∂ f 21 + ∂ L ∂ o 12 ⋅ ∂ o 12 ∂ f 21 + ∂ L ∂ o 21 ⋅ ∂ o 21 ∂ f 21 + ∂ L ∂ o 22 ⋅ ∂ o 22 ∂ f 21 ∂ L ∂ f 22 = ∂ L ∂ o 11 ⋅ ∂ o 11 ∂ f 22 + ∂ L ∂ o 12 ⋅ ∂ o 12 ∂ f 22 + ∂ L ∂ o 21 ⋅ ∂ o 21 ∂ f 22 + ∂ L ∂ o 22 ⋅ ∂ o 22 ∂ f 22 \begin{cases} \begin{aligned} \frac{\partial \mathcal L}{\partial f_{12}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot \frac{\partial o_{11}}{\partial f_{12}} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot \frac{\partial o_{12}}{\partial f_{12}} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot \frac{\partial o_{21}}{\partial f_{12}} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot \frac{\partial o_{22}}{\partial f_{12}} \\ \frac{\partial \mathcal L}{\partial f_{21}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot \frac{\partial o_{11}}{\partial f_{21}} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot \frac{\partial o_{12}}{\partial f_{21}} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot \frac{\partial o_{21}}{\partial f_{21}} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot \frac{\partial o_{22}}{\partial f_{21}} \\ \frac{\partial \mathcal L}{\partial f_{22}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot \frac{\partial o_{11}}{\partial f_{22}} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot \frac{\partial o_{12}}{\partial f_{22}} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot \frac{\partial o_{21}}{\partial f_{22}} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot \frac{\partial o_{22}}{\partial f_{22}} \\ \end{aligned} \end{cases} ⎩ ⎨ ⎧∂f12∂L=∂o11∂L⋅∂f12∂o11+∂o12∂L⋅∂f12∂o12+∂o21∂L⋅∂f12∂o21+∂o22∂L⋅∂f12∂o22∂f21∂L=∂o11∂L⋅∂f21∂o11+∂o12∂L⋅∂f21∂o12+∂o21∂L⋅∂f21∂o21+∂o22∂L⋅∂f21∂o22∂f22∂L=∂o11∂L⋅∂f22∂o11+∂o12∂L⋅∂f22∂o12+∂o21∂L⋅∂f22∂o21+∂o22∂L⋅∂f22∂o22
对应的结果可表示为:
{ ∂ L ∂ f 12 = ∂ L ∂ o 11 ⋅ x 12 + ∂ L ∂ o 12 ⋅ x 13 + ∂ L ∂ o 21 ⋅ x 22 + ∂ L ∂ o 22 ⋅ x 23 ∂ L ∂ f 21 = ∂ L ∂ o 11 ⋅ x 21 + ∂ L ∂ o 12 ⋅ x 22 + ∂ L ∂ o 21 ⋅ x 31 + ∂ L ∂ o 22 ⋅ x 32 ∂ L ∂ f 22 = ∂ L ∂ o 11 ⋅ x 22 + ∂ L ∂ o 12 ⋅ x 23 + ∂ L ∂ o 21 ⋅ x 32 + ∂ L ∂ o 22 ⋅ x 33 \begin{cases} \begin{aligned} \frac{\partial \mathcal L}{\partial f_{12}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot x_{12} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot x_{13} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot x_{22} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot x_{23} \\ \frac{\partial \mathcal L}{\partial f_{21}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot x_{21} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot x_{22} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot x_{31} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot x_{32} \\ \frac{\partial \mathcal L}{\partial f_{22}} = \frac{\partial \mathcal L}{\partial o_{11}} \cdot x_{22} + \frac{\partial \mathcal L}{\partial o_{12}} \cdot x_{23} + \frac{\partial \mathcal L}{\partial o_{21}} \cdot x_{32} + \frac{\partial \mathcal L}{\partial o_{22}} \cdot x_{33} \\ \end{aligned} \end{cases} ⎩ ⎨ ⎧∂f12∂L=∂o11∂L⋅x12+∂o12∂L⋅x13+∂o21∂L⋅x22+∂o22∂L⋅x23∂f21∂L=∂o11∂L⋅x21+∂o12∂L⋅x22+∂o21∂L⋅x31+∂o22∂L⋅x32∂f22∂L=∂o11∂L⋅x22+∂o12∂L⋅x23+∂o21∂L⋅x32+∂o22∂L⋅x33
根据上述结果,我们可以发现,损失函数 L \mathcal L L关于卷积核 F \mathcal F F的导数 ∂ L ∂ F \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal F}\end{aligned} ∂F∂L就是:数据矩阵 X \mathcal X X和导数矩阵 ∂ L ∂ O \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal O}\end{aligned} ∂O∂L的卷积结果。其中卷积核就是导数矩阵:
∂ L ∂ F = Convolution [ ( x 11 , x 12 , x 13 x 21 , x 22 , x 23 x 31 , x 32 , x 33 ) , ( ∂ L ∂ o 11 , ∂ L ∂ o 12 ∂ L ∂ o 21 , ∂ L ∂ o 22 ) ] \frac{\partial \mathcal L}{\partial \mathcal F} = \text{Convolution} \left[\begin{pmatrix} x_{11},x_{12},x_{13} \\ x_{21},x_{22},x_{23} \\ x_{31},x_{32},x_{33} \end{pmatrix},\begin{pmatrix} \begin{aligned} \frac{\partial \mathcal L}{\partial o_{11}},\frac{\partial \mathcal L}{\partial o_{12}} \\ \frac{\partial \mathcal L}{\partial o_{21}},\frac{\partial \mathcal L}{\partial o_{22}} \\ \end{aligned} \end{pmatrix}\right] ∂F∂L=Convolution x11,x12,x13x21,x22,x23x31,x32,x33 , ∂o11∂L,∂o12∂L∂o21∂L,∂o22∂L
依然基于上述的场景构建,区别在于此时的 X \mathcal X X不是输入层,而是某一个隐藏层的输出,以为特征 x 11 x_{11} x11例,计算它的反向传播过程。
回归上式,其中
x 11 x_{11} x11仅在
o 11 o_{11} o11中出现过一次,并且
∂ o 11 ∂ x 11 = f 11 \begin{aligned}\frac{\partial o_{11}}{\partial x_{11}} =f_{11}\end{aligned} ∂x11∂o11=f11,后续同理。
有意思的是,越趋近于边缘上的项,与其相关的导数项就越少。其中
x 22 x_{22} x22位于矩阵的最中间,在输出中出现了
4 4 4次;相反,在角落处的
x 11 x_{11} x11仅出现了一次。
这个翻转与‘上述卷积函数到卷积核’的反转方式相同。
感兴趣的小伙伴可以将所有的
9 9 9项列出来试一试。
相关参考:
【低层视觉】低层视觉中常见的卷积核汇总
从“卷积”、到“图像卷积操作”、再到“卷积神经网络”,“卷积”意义的3次改变
超详细一步一步推导反向传播(4)—卷积层卷积核的反向传播过程
超详细一步一步推导反向传播(5)—卷积层输入的反向传播过程