Convolution is convolution; it’s NOT dot product
我真的是出离愤怒。我不知道最开始把 convolution 看做 dot product 的人是怎么想的!有 convolution 的公式不用,非要用这么蹩脚的 intuition?而且明显 convolution 和 Hadamard product 的关系更大一点呢,咋没见人提?
本文主要参考:
- Wikipedia: Convolution
- HIPR2: Convolution
- StackExchange: In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
- StackExchange: What is the physical meaning of the convolution of two signals?
1-D ConvolutionPermalink
首先 convolution 不是限定于 matrix 间、也不是限定于 tensor 间的运算,它其实是两个 functions 之间的运算:
在 engineering 领域也有
因为
物理上的一个 intuition 是:if signal
For complex-valued functions
2-D ConvolutionPermalink
一般有:
如果
Matrix 2-D Convolution for Image Processing / Image & KernelPermalink
如果我们把 matrix
where 0
记起)。
但是要注意在 image processing 领域,这个 matrix 的函数式写法没有这么简单。一般有一个 image matrix
where
的作用是将 上下翻转 (horizontally flip) 的作用是将 左右翻转 (vertically flip)
如果有 matrix
- 注意,如果下标从
1
开始计的话,上面的下标都要+1
- 另外,参考 kernel method 的思想,实际应用中我们并不需要构造
和 ,直接写出 的形式拿来用就好了
考虑个具体的例子,假设
这个例子给出了一个很直观的 intuition:
- 把 kernel
覆盖在 image 之上, 对齐到 (左上角对齐) - 移动 kernel
使 对齐到 ,假设覆盖到的 image 的部分是 - 那么
(sum of Hadamard product)- 我再次强调一遍,这不是 dot product!
很明显我们可以把
进而有:
所以 matrix
Comments