【发布时间】:2016-04-22 05:25:02
【问题描述】:
我从here 了解到卷积神经网络。然后我开始玩torch7。我对 CNN 的卷积层感到困惑。
从教程中,
1
The neurons in a layer will only be connected to a small region of the layer before it, instead of all of the neurons in a fully-connected manner.
2
For example, suppose that the input volume has size [32x32x3], (e.g. an RGB CIFAR-10 image). If the receptive field is of size 5x5, then each neuron in the Conv Layer will have weights to a [5x5x3] region in the input volume, for a total of 5*5*3 = 75 weights.
3
如果输入层是[32x32x3],CONV layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and the region they are connected to in the input volume. This may result in volume such as [32x32x12].
我开始研究 CONV 层对图像的作用。我在torch7中做到了。这是我的实现,
require 'image'
require 'nn'
i = image.lena()
model = nn.Sequential()
model:add(nn.SpatialConvolutionMM(3, 10, 5, 5)) --depth = 3, #output layer = 10, filter = 5x5
res = model:forward(i)
itorch.image(res)
print(#i)
print(#res)
3
512
512
[torch.LongStorage of size 3]
10
508
508
[torch.LongStorage of size 3]
现在让我们看看 CNN 的结构
所以,我的问题是,
问题 1
卷积是这样完成的吗?假设我们拍摄了 32x32x3 的图像。并且有 5x5 过滤器。那么5x5过滤器会通过整个32x32图像并产生卷积图像吗?好的,所以在整个图像上滑动 5x5 过滤器,我们得到一张图像,如果有 10 个输出层,我们得到 10 张图像(如您从输出中看到的那样)。我们如何得到这些? (如果需要,请参见图片以进行说明)
问题 2
conv 层的神经元数量是多少?是输出层数吗?在我上面写的代码中,model:add(nn.SpatialConvolutionMM(3, 10, 5, 5))。是10吗? (输出层数?)
如果是这样,第 2 点没有任何意义。根据If the receptive field is of size 5x5, then each neuron in the Conv Layer will have weights to a [5x5x3] region in the input volume, for a total of 5*5*3 = 75 weights. 那么这里的重量是多少?我对此感到非常困惑。在 torch 中定义的模型中,没有权重。那么重量是如何在这里发挥作用的呢?
有人能解释一下是怎么回事吗?
【问题讨论】:
标签: machine-learning computer-vision neural-network torch conv-neural-network