machine-learning - Caffe 卷积层权重和尺寸

标签 machine-learning neural-network deep-learning caffe conv-neural-network

我发现了这个不错的article它直观地解释了卷积网络的工作原理。

现在尝试了解 caffe 转换层内部到底发生了什么:

输入数据形状为 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 具有所有权重:每个平面 (13) 每个滤波器 (128) 一个 7x7 矩阵。

在 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 的 prototxt 格式。调整到新格式将为您提供

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 个 channel ,空间维度为 19 x 19。
应用 128 个 7 x 7 的滤波器(每个滤波器应用于所有 13 个输入 channel )意味着您有 128 个 形状 13 x 7 x 7 的滤波器(这是第一层的参数)。使用单个输出 channel 1 x 1 x 19 x 19 应用每个过滤器结果,因为您有 128 个这样的过滤器,所以最终会得到 1 x 128 x 19 x 19 输出。

第二层的参数是偏差项 - 每个过滤器结果的加性标量。您可以通过添加

来关闭偏差项
bias_term: false

到您层的卷积参数

您可以阅读有关卷积层的更多信息 here .

关于奖励问题,Eliethesaiyan已经在his comment中回答得很好了.

关于machine-learning - Caffe 卷积层权重和尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44750133/

相关文章:

python - 建立一个keras模型

tensorflow - Darkflow 在演示上准确,但在代码上不准确

python-3.x - Pytorch autograd.grad 如何写多个输出的参数?

python - 平均(似然)编码

algorithm - 批处理和随机梯度下降之间的算法复杂度差异是什么

R:使用带插入符号的 Ranger、tuneGrid 参数

machine-learning - 多变量推荐系统

neural-network - 深度 Q 学习适合解决 Cartpole 任务吗?

deep-learning - 如何在 Pytorch 中添加 EfficieNet 预训练模型的最后一个分类层?

python-2.7 - Tensorflow 返回相似图像