在泛函分析中,卷积、旋积或摺积(英语:Convolution)是通过两个函数f和g生成第三个函数的一种数学算子,表征函数f与g经过翻转和平移的重叠部分的面积。如果将参加卷积的一个函数看作区间的指示函数,卷积还可以被看作是“滑动平均”的推广。
卷积公式:
![[原]卷积是什么?](http://www.codesec.net/app_attach/201703/11/20170311_422_543402_0.png!web)
相关运算过程:
![[原]卷积是什么?](http://www.codesec.net/app_attach/201703/11/20170311_422_543402_1.gif)
![[原]卷积是什么?](http://www.codesec.net/app_attach/201703/11/20170311_422_543402_2.gif)
离散卷积是两个离散序列和之间按照一定的规则将它们的有关序列值分别两两相乘再相加的一种特殊的运算。在工程上离散卷积有着广泛的应用。例如为了将数字信号进行滤波,可以将表示成离散序列的该信号x(n)与数字滤波器的冲激响应h(n)进行卷积。
![[原]卷积是什么?](http://www.codesec.net/app_attach/201703/11/20170311_422_543402_3.png!web)
numpy. convolve ( a , v , mode='full' )
Returns the discrete, linear convolution of two one-dimensional sequences.
The convolution operator is often seen in signal processing, where it models the effect of a linear time-invariant system on a signal [R17] . In probability theory, the sum of two independent random variables is distributed according to the convolution of their individual distributions.If v is longer than a , the arrays are swapped before computation.
Parameters:a : (N,) array_like
First one-dimensional input array.
v : (M,) array_like
Second one-dimensional input array.
mode : {‘full’, ‘valid’, ‘same’}, optional
‘full’:By default, mode is ‘full’. This returns the convolution at each point of overlap, with an output shape of (N+M-1,). At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen.
‘same’:Mode ‘same’ returns output of length max(M, N) . Boundary effects are still visible.
‘valid’:Mode ‘valid’ returns output of length max(M, N) - min(M, N) + 1 . The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect.
Returns:out : ndarray
Discrete, linear convolution of a and v .
例子:
#python 3.5.3 #2017-03-09 蔡军生 http://blog.csdn.net/caimouse # import numpy as np import matplotlib.pyplot as plt f = [1,2,3,4] g = [1,1,3] cnn = np.convolve([1,2,3,4],[1,1,3],'full') print(f) print(g) print(cnn) cnn = np.convolve([1,2,3,4],[1,1,3],'same') print(cnn) plt.plot(f, 'r-') plt.plot(g, 'g-') plt.plot(cnn, 'b-') plt.show()输出如下图:
[1, 2, 3, 4] [1, 1, 3] [ 1 3 8 13 13 12] [ 3 8 13 13]![[原]卷积是什么?](http://www.codesec.net/app_attach/201703/11/20170311_422_543402_4.png!web)
1.TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
2. C++标准模板库从入门到精通http://edu.csdn.net/course/detail/3324
3.跟老菜鸟学C++