zoukankan      html  css  js  c++  java
  • Convolution & Pooling exercise

    convolution

    First, we want to compute σ(Wx(r,c) + b) for all valid (r,c) (valid meaning that the entire 8x8 patch is contained within the image; this is as opposed to a full convolution, which allows the patch to extend outside the image, with the area outside the image assumed to be 0), where W and b are the learned weights and biases from the input layer to the hidden layer, and x(r,c) is the 8x8 patch with the upper left corner at (r,c).

    卷积操作是为了解除输入层和隐藏层之间的全链接 —— 全链接会带来很高的计算成本

    这样只是对局部patch进行sigmoid(W,b),卷积操作使用matlab的conv2函数

    First, conv2 performs a 2-D convolution, but you have 5 "dimensions" - image number, feature number, row of image, column of image, and (color) channel of image - that you want to convolve over. Because of this, you will have to convolve each feature and image channel separately for each image, using the row and column of the image as the 2 dimensions you convolve over. This means that you will need three outer loops over the image number imageNum, feature number featureNum, and the channel number of the image channel.

    卷积的作用对象不是直接的像素点,而是图像中提取出的特征

    Second, because of the mathematical definition of convolution, the feature matrix must be "flipped" before passing it toconv2. The following implementation tip explains the "flipping" of feature matrices when using MATLAB's convolution

    使用matlab计算卷积,需要对卷积patch进行反转

    In particular, you did the following to the patches:

    1. subtract the mean patch, meanPatch to zero the mean of the patches
    2. ZCA whiten using the whitening matrix ZCAWhite.

    These same three steps must also be applied to the input image patches.

    Taking the preprocessing steps into account, the feature activations that you should compute is sigma(W(T(x-ar{x})) + b), whereT is the whitening matrix and ar{x} is the mean patch. Expanding this, you obtain sigma(WTx - WTar{x} + b), which suggests that you should convolve the images with WT rather than W as earlier, and you should add (b - WTar{x}), rather than just b toconvolvedFeatures, before finally applying the sigmoid function.

    对每个patch计算其均值和ZCA whiten

    Pooling

    首先在前面的使用convolution时是利用了图像的stationarity特征,即不同部位的图像的统计特征是相同的,那么在使用convolution对图片中的某个局部部位计算时,得到的一个向量应该是对这个图像局部的一个特征,既然图像有stationarity特征,那么对这个得到的特征向量进行统计计算的话,所有的图像局部块应该也都能得到相似的结果。对convolution得到的结果进行统计计算过程就叫做pooling,由此可见pooling也是有效的。常见的pooling方法有max pooling和average pooling等。并且学习到的特征具有旋转不变性

  • 相关阅读:
    P1017 进制转换
    P1100 高低位交换
    P1469 找筷子
    P1866 编号
    SQL常用语句(T-SQL、PL/SQL)
    Proxyer内网穿透配置教程
    使用JS检测自定义协议是否存在
    C# 代码启动ClickOnce应用
    SQL Server 异地备份到远程共享文件夹异常处理
    发布ClickOnce应用程序步骤与URL传参应用
  • 原文地址:https://www.cnblogs.com/sprint1989/p/3998506.html
Copyright © 2011-2022 走看看