matcaffe的blob維度順序

2021-09-08 22:42:37 字數 1101 閱讀 9853

matcaffe是caffe的matlab介面。caffe本身是c++寫的,其blob的維度順序是[n,c,h,w],n表示batchsize,c表示channel數目,h表示feature map的height, w則是width

而在matcaffe中,blob的順序則是[w,h,c,n]。這是預設的順序!所以在faster-rcnn的matlab**中,當載入了proposal_test.prototxt後,發現其網路輸入是:

input: "data"

input_dim: 1

input_dim: 3

input_dim: 224

input_dim: 224

一開始還奇怪,為啥在matlab中設定斷點後輸出網路的blob的結構是這樣的:

k>> rpn_net.blobs('data').shape

ans =

224 224 3 1

為啥不是[1,3,224,224]這個在prototxt中指定的順序呢?雖然官方caffe的tutorial裡也說了,matcaffe的blob順序就是[w,h,c,n]

翻看matcaffe的**:caffe_.cpp,找到370行左右:

// usage: caffe_('blob_get_shape', hblob)

static void blob_get_shape(mex_args)

plhs[0] = mx_shape;

}

其中最關鍵的是這個:

for (int blob_axis = 0, mat_axis = num_axes - 1; blob_axis < num_axes;

++blob_axis, --mat_axis)

這裡面mat_axis這個索引是倒序的,從3到0;而blob_axis這個索引是正序增加的,從0到3。因此最終的結果是:matcaffe中的blob維度順序和caffe中順序完全相反,是[w,h,c,n]

matcaffe的blob維度順序

matcaffe是caffe的matlab介面。caffe本身是c 寫的,其blob的維度順序是 n,c,h,w n表示batchsize,c表示channel數目,h表示feature map的height,w則是width 而在matcaffe中,blob的順序則是 w,h,c,n 這是預設的順...

ubuntu 14 04下matcaffe的配置

然後操作如下 sudo update alternatives install usr bin gcc gcc usr bin gcc 4.4 40 sudo update alternatives install usr bin g g usr bin g 4.4 40 此時可以使用 gcc v ...

Blob的基本用法

blob簡介 在caffe中blob相當於tensorflow的tensor,即張量,是caffe框架中資料流的基本儲存單位,caffe中關於資料的運算和儲存都是基於blob進行的。blob的使用 blob是乙個模板類,在建立物件時需要制定模板引數,例如 blob a 宣告乙個blob物件a cou...