如何使用作物参数

如何使用作物参数

本文介绍了caffe全卷积cnn-如何使用作物参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的问题训练一个完全卷积的网络。我正在使用,它需要两个底部Blob,并输出一个顶部Blob。让我们将底部Blob称为 A B ,将顶部Blob称为 T

According to the Crop layer documentation, it takes two bottom blobs and outputs one top blob. Let's call the bottom blobs as A and B, the top blob as T.

A -> 32 x 3 x 224 x 224
B -> 32 x m x n x p

然后,

T -> 32 x m x n x p

关于轴参数,来自文档:

Regarding axis parameter, from docs:

这意味着,如果我们设置 axis = 1 ,它将裁剪尺寸1、2、3。如果 axis = 2 ,则 T 的大小应为 32 x 3 xnxp 。您还可以将axis设置为负值,例如 -1 ,这表示最后一个尺寸,即本例中为3。

which means, if we set axis = 1, then it will crop dimensions 1, 2, 3. If axis = 2, then T would have been of the size 32 x 3 x n x p. You can also set axis to a negative value, such as -1, which would mean the last dimension, i.e. 3 in this case.

关于偏移量参数,我检出了$ CAFFE_ROOT / src / caffe / proto / caffe.proto(在第630行),我没有找到偏移量参数的任何默认值,因此我假设您必须提供该参数,否则将导致错误。但是,我可能是错的。

Regarding offset parameter, I checked out $CAFFE_ROOT/src/caffe/proto/caffe.proto (on line 630), I did not find any default value for offset parameter, so I assume that you have to provide that parameter, otherwise it will result in an error. However, I may be wrong.

现在,Caffe知道您需要第一个大小为 m 的对象轴。我们仍然需要告诉Caffe从哪里种植。这就是偏移量的来源。如果偏移量为 10 ,那么大小为 m 的对象将从<$开始c $ c> 10 并以 10 + m-1 结尾(总大小为 m )。在所有维度(由确定)中为该偏移量设置一个值,以该量为单位,要记住吗?在这种情况下, 1、2、3 )。否则,如果要不同地裁剪每个尺寸,则必须指定等于要裁剪的尺寸数量的偏移量(在本例中为3)。因此,总结一下,

Now, Caffe knows that you need a blob of size m on the first axis. We still need to tell Caffe from where to crop. That's where offset comes in. If offset is 10, then your blob of size m will be cropped starting from 10 and end at 10+m-1 (for a total of size m). Set one value for offset to crop by that amount in all the dimensions (which are determined by axis, remember? In this case 1, 2, 3). Otherwise, if you want to crop each dimension differently, you have to specify number of offsets equal to the number of dimensions being cropped (in this case 3). So to sum up all,

如果您的Blob大小为 32 x 3 x 224 x 224 想要裁剪尺寸为 32 x 3 x 32 x 64 的中心部分,则可以按以下方式编写裁剪层:

If you have a blob of size 32 x 3 x 224 x 224 and you want to crop a center part of size 32 x 3 x 32 x 64, then you would write the crop layer as follows:

layer {
  name: "T"
  type: "Crop"
  bottom: "A"
  bottom: "B"
  top: "T"
  crop_param {
      axis: 2
      offset: 96
      offset: 80
  }
}

这篇关于caffe全卷积cnn-如何使用作物参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 11:52