美文网首页
无标题文章

无标题文章

作者: daiab | 来源:发表于2017-02-05 23:00 被阅读0次

    ### 特殊的网络结构

    **卷积神经网络**

    卷积神经网络是如何计算的非常简单。但还是先简单说说数学中的卷积是怎么回事(详细可以参考[wiki](https://en.wikipedia.org/wiki/Convolution)),再回过头来则能更好理解卷积神经网络。

    卷积在数学中大概是说,两个函数通过做卷积,可以生成一个新的函数。我用两个最简单的函数画图示范一下

    $$函数1:f(x)=\begin{cases}

    x & \text{ if } x \geq  0\\

    0 & \text{ if } x < 0

    \end{cases}$$

    $$函数2:g(x)=\begin{cases}

    1 & \text{ if } 0 \leq x \leq  1\\

    0 & \text{ if } x= others

    \end{cases}$$

    把他们画下来就是:

    ```python

    import numpy as np

    import matplotlib.pyplot as plt

    %matplotlib inline

    x1 = np.linspace(0, 3, 30)

    y1 = x1

    x2 = np.linspace(0, 1, 2)

    y2 = np.ones_like(x2)

    plt.plot(x1, y1, label="f(x)")

    plt.plot(x2, y2, label="g(x)")

    plt.plot(-x2, y2, label="g(-x)")

    plt.legend()

    plt.show()

    ```

    ![png](output_1_0.png)

    对f(x),g(x)做卷积,公式为:

    $$(f*g)(t) = \int_{-\infty }^{+\infty }f(x)g(t-x)dx$$

    现在来解释这个式子对于上边的f(x)和g(x)来说,到底做了什么操作?

    现在设想我们要求$(f*g)(t=0)$的值,那么卷积:

    $$(f*g)(t=0) = \int_{-\infty }^{+\infty }f(x)g(-x)dx$$

    从上边图可以看出f(x)g(-x)乘积为0,因此积分也为0。

    再假设我们要求t=0.5时卷积的值,那么卷积:

    $$(f*g)(t=0.5) = \int_{-\infty }^{+\infty }f(x)g(0.5-x)dx$$

    把f(x)和g(0.5-x)在图上画出来:

    ```python

    x1 = np.linspace(0, 3, 30)

    y1 = x1

    x2 = np.linspace(-0.5, 0.5, 2)

    y2 = np.ones_like(x2)

    plt.plot(x1, y1, label="f(x)")

    plt.plot(x2, y2, label="g(0.5-x)")

    plt.legend()

    plt.show()

    ```

    ![png](output_3_0.png)

    因此f(x)和g(0.5-x)的相乘之后的积分,就是f(x)在0

    相关文章

      网友评论

          本文标题:无标题文章

          本文链接:https://www.haomeiwen.com/subject/sgcyittx.html