[英]Caffe conv layer weights and dimensions
我偶然发现了这篇很好的文章 ,它直观地解释了如何运行。
现在试图了解caffe conv层内部正在发生的事情:
输入数据形状为1 x 13 x 19 x 19,以及128个滤波器转换层:
layers {
name: "conv1_7x7_128"
type: CONVOLUTION
blobs_lr: 1.
blobs_lr: 2.
bottom: "data"
top: "conv2"
convolution_param {
num_output: 128
kernel_size: 7
pad: 3
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
如果我理解正确,图层输出形状是1 x 128 x 19 x 19。
在net->layers()[1]->blobs()
查看图层的权重形状:
layer 1: type Convolution 'conv1_7x7_128'
blob 0: 128 13 7 7
blob 1: 128
看起来blob 0具有所有的重量:每个平面一个7x7矩阵(13)每个滤波器(128)。
在1 x 13 x 19 x 19数据上使用blob 0进行卷积,如果我理解正确,我们最终得到128 x 13 x 19 x 19输出(有填充,因此每个7x7矩阵为每个像素生成一个数字)
128 x 13 x 19 x 19如何变成图层的1 x 128 x 19 x 19输出?
blob 1中的128个权重是多少?
奖金问题:什么是blobs_lr
?
您正在引用旧版本的caffe原型文本格式。 调整为新格式将给你
layer { # layer and not layer*s*
name: "conv1_7x7_128"
type: "Convolution" # tyoe as string
param { lr_mult: 1. } # instead of blobs_lr
param { lr_mult: 2. } # instead of blobs_lr
bottom: "data"
top: "conv2"
convolution_param {
num_output: 128
kernel_size: 7
pad: 3
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
如果您输入的数据shape
1 x 13 x 19 x 19,则表示您的batch_size
为1,您有13个通道,空间尺寸为19 x 19。
应用128个7 x 7过滤器(每个过滤器应用于所有13个输入通道)意味着您有128个shape
13 x 7 x 7的过滤器(这是您第一层参数的shape
)。 使用单个输出通道1 x 1 x 19 x 19应用每个滤波器结果,因为您有128个这样的滤波器,最终得到1 x 128 x 19 x 19输出。
第二层的参数是偏差项 - 每个滤波器结果的附加标量。 您可以通过添加来关闭偏差项
bias_term: false
到你层的convolution_param
。
您可以在此处阅读有关卷积图层的更多信息。
至于奖金问题,Eliethesaiyan在他的评论中已经很好地回答了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.