IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]卷积是什么?

    caimouse发表于 2017-03-09 21:24:40
    love 0

    在泛函分析中,卷积、旋积或摺积(英语:Convolution)是通过两个函数f和g生成第三个函数的一种数学算子,表征函数f与g经过翻转和平移的重叠部分的面积。如果将参加卷积的一个函数看作区间的指示函数,卷积还可以被看作是“滑动平均”的推广。

    卷积公式:



    相关运算过程:

    离散卷积是两个离散序列和之间按照一定的规则将它们的有关序列值分别两两相乘再相加的一种特殊的运算。在工程上离散卷积有着广泛的应用。例如为了将数字信号进行滤波,可以将表示成离散序列的该信号x(n)与数字滤波器的冲激响应h(n)进行卷积。



    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]


    1. TensorFlow入门基本教程

    http://edu.csdn.net/course/detail/4369

    2. C++标准模板库从入门到精通 

    http://edu.csdn.net/course/detail/3324

    3.跟老菜鸟学C++

    http://edu.csdn.net/course/detail/2901

    4. 跟老菜鸟学python

    http://edu.csdn.net/course/detail/2592

    5. 在VC2015里学会使用tinyxml库

    http://edu.csdn.net/course/detail/2590

    6. 在Windows下SVN的版本管理与实战 

     http://edu.csdn.net/course/detail/2579

    7.Visual Studio 2015开发C++程序的基本使用 

    http://edu.csdn.net/course/detail/2570

    8.在VC2015里使用protobuf协议

    http://edu.csdn.net/course/detail/2582

    9.在VC2015里学会使用MySQL数据库

    http://edu.csdn.net/course/detail/2672




沪ICP备19023445号-2号
友情链接