DL之CNN可视化:利用SimpleConvNet算法【3层,im2col优化】基于mnist数据集训练并对卷积层输出进行可视化

DL之CNN可视化:利用SimpleConvNet算法【3层,im2col优化】基于mnist数据集训练并对卷积层输出进行可视化

导读
利用SimpleConvNet算法基于mnist数据集训练并对卷积层输出进行可视化,理解CNN卷积层的输出,进一步了解神经网络。
1、图中右边,有规律的滤波器在“观察”什么,
#(1)、可知它在观察边缘(颜色变化的分界线)和斑块(局部的块状区域)等。比如,左半部分为白色、右半部分为黑色的滤波器的情况下,会对垂直方向上的边缘有响应。
#(2)、对水平方向上和垂直方向上的边缘有响应的滤波器:输出图像1中,垂直方向的边缘上出现白色像素,输出图像2中,水平方向的边缘上出现很多白色像素
#(3)、图中显示了选择两个学习完的滤波器对输入图像进行卷积处理时的结果。我们发现“滤波器1”对垂直方向上的边缘有响应,“滤波器2”对水平方向上的边缘有响应。由此可知,卷积层的滤波器会提取边缘或斑块等原始信息。而刚才实现的CNN会将这些原始信息传递给后面的层。


输出结果

设计思路

核心代码

def filter_show(filters, suptitle, nx=8, margin=3, scale=10,):
    FN, C, FH, FW = filters.shape
    ny = int(np.ceil(FN / nx))      

    fig = plt.figure()               fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)

    for i in range(FN):
        ax = fig.add_subplot(ny, nx, i+1, xticks=[], yticks=[])
        ax.imshow(filters[i, 0], cmap=plt.cm.gray_r, interpolation='nearest')
    plt.suptitle(suptitle)
    plt.show()

filter_show(network.params['W1'],suptitle='CNN(SimpleConvNet): Weight after random initialization on mnist')

network.load_params("params.pkl")          

filter_show(network.params['W1'],suptitle='CNN(SimpleConvNet): Weight after learning on mnist(params.pkl)')

相关论文

CNN可视化相关论文

[1] Zeiler M D , Fergus R . Visualizing and Understanding Convolutional Networks[J]. 2013.
地址01:https://arxiv.org/abs/1311.2901
地址02:http://xueshu.baidu.com/usercenter/paper/show?paperid=908cd647dd96ee1d41402d811bf32178&site=xueshu_se

[2] Mahendran A , Vedaldi A . Understanding Deep Image Representations by Inverting Them[J]. 2014.
地址01:https://arxiv.org/abs/1412.0035
地址02:http://xueshu.baidu.com/usercenter/paper/show?paperid=1fe99e4c98b124fd0672fc9ef07f8c7c&site=xueshu_se

[3] Donglai Wei, Bolei Zhou, Antonio Torralba, William T. Freeman(2015): mNeuron: A Matlab Plugin to Visualize Neurons from DeepModels.  《mNeuron: A Matlab Plugin to Visualize Neurons from Deep Models
地址01:http://vision03.csail.mit.edu/cnn_art/?utm_content=buffer2ff9c&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer
地址02:http://www.myzaker.com/article/5951f9091bc8e0e263000018/

(0)

相关推荐