Does caffe support N-D Convolution and N-D Pooling?

1,526 views
Skip to first unread message

sky

unread,
Oct 27, 2015, 11:37:05 PM10/27/15
to Caffe Users
Hello,

I want to use 3D convolution and 3D pooling in Caffe.

I tried 3D convolution referring to #2049, and got an error

F1028 11:17:42.342301  8639 blob.hpp:140] Check failed: num_axes() <= 4 (5 vs. 4) Cannot use legacy accessors on Blobs with > 4 axes.


As @Tgaaly said, I uncomment a sentence "CHECK_LE(num_axes(), 4) << "Cannot use legacy accessors on Blobs with > 4 axes.";" (caffe/include/caffe/blob.hpp), and the program seems to run.


The first question is will things go right?


Then, I tried 3D pooling, but got an error
F1028 12:09:38.425106 10604 pooling_layer.cpp:81] Check failed: 4 == bottom[0]->num_axes() (4 vs. 5) Input must have 4 axes, corresponding to (num, channels, height, width)

The second question is does Caffe support N-D pooling?


It is shown below the part of the execution result. I use the HDF5 format file as 3D input.
----------
I1028 12:09:38.418767 10604 layer_factory.hpp:76] Creating layer hoge
I1028 12:09:38.418849 10604 net.cpp:106] Creating Layer hoge
I1028 12:09:38.418920 10604 net.cpp:411] hoge -> data
I1028 12:09:38.418995 10604 net.cpp:411] hoge -> label
I1028 12:09:38.419075 10604 hdf5_data_layer.cpp:79] Loading list of HDF5 filenames from: sample_data_list.txt
I1028 12:09:38.419239 10604 hdf5_data_layer.cpp:93] Number of HDF5 files: 1
I1028 12:09:38.420356 10604 hdf5.cpp:32] Datatype class: H5T_FLOAT
I1028 12:09:38.420685 10604 net.cpp:150] Setting up hoge
I1028 12:09:38.420794 10604 net.cpp:157] Top shape: 1 1 3 3 3 (27)
I1028 12:09:38.420886 10604 net.cpp:157] Top shape: 1 (1)
I1028 12:09:38.420989 10604 net.cpp:165] Memory required for data: 112
I1028 12:09:38.421082 10604 layer_factory.hpp:76] Creating layer conv1
I1028 12:09:38.421180 10604 net.cpp:106] Creating Layer conv1
I1028 12:09:38.421272 10604 net.cpp:454] conv1 <- data
I1028 12:09:38.421367 10604 net.cpp:411] conv1 -> conv1
I1028 12:09:38.421893 10604 net.cpp:150] Setting up conv1
I1028 12:09:38.421996 10604 net.cpp:157] Top shape: 1 6 2 2 2 (48)
I1028 12:09:38.422081 10604 net.cpp:165] Memory required for data: 304
I1028 12:09:38.422185 10604 layer_factory.hpp:76] Creating layer sigmoid1
I1028 12:09:38.422282 10604 net.cpp:106] Creating Layer sigmoid1
I1028 12:09:38.422370 10604 net.cpp:454] sigmoid1 <- conv1
I1028 12:09:38.422473 10604 net.cpp:411] sigmoid1 -> sigmoid1
I1028 12:09:38.422577 10604 net.cpp:150] Setting up sigmoid1
I1028 12:09:38.422669 10604 net.cpp:157] Top shape: 1 6 2 2 2 (48)
I1028 12:09:38.422752 10604 net.cpp:165] Memory required for data: 496
I1028 12:09:38.422837 10604 layer_factory.hpp:76] Creating layer pool1
I1028 12:09:38.425029 10604 net.cpp:106] Creating Layer pool1
I1028 12:09:38.425053 10604 net.cpp:454] pool1 <- sigmoid1
I1028 12:09:38.425071 10604 net.cpp:411] pool1 -> pool1
F1028 12:09:38.425106 10604 pooling_layer.cpp:81] Check failed: 4 == bottom[0]->num_axes() (4 vs. 5) Input must have 4 axes, corresponding to (num, channels, height, width)
----------

The attached file is a data set that I use.
Thank you for your kind cooperation.
hdf5_3d_test.zip

Toru Hironaka

unread,
Dec 18, 2015, 11:34:32 AM12/18/15
to Caffe Users
Hi, Sky 

Please see #2442 and #2824. I used #2442 to do 3D conv and pooling. It worked. 

Toru 

sky

unread,
Dec 21, 2015, 9:23:17 PM12/21/15
to Caffe Users
Hi, Toru

Thank you for the information.
As far as
the use of
attached data, It worked to the end using #2442.
I'll try it for the real data.

Sky

2015年12月19日土曜日 1時34分32秒 UTC+9 Toru Hironaka:

Toru Hironaka

unread,
Dec 22, 2015, 10:33:23 AM12/22/15
to Caffe Users
Hi, Sky

I confirmed my training has been working but I have not gotten good results yet for accuracy and loss. I am training my data for classification. If you successfully train and got good results, Please let me know your model layer and solver settings. 

Toru

Chuan Wang

unread,
Jan 8, 2016, 4:43:14 AM1/8/16
to Caffe Users
Hi, sky

Finally how did you make the caffe support 3D pooling? I read #2442, but it seems to use Python Caffe to do that. I want to use it in C++. Actually I comment the code about 

pooling_layer.cpp:81 Check failed: 4 == bottom[0]->num_axes() (4 vs. 5)

but the result is not 3D pooling, it only pools height and width. Could you tell me your method?

Best,
Chuan


在 2015年12月22日星期二 UTC+8上午10:23:17,sky写道:
Message has been deleted

sky

unread,
Jan 9, 2016, 2:03:21 AM1/9/16
to Caffe Users
Hi, Chuan

I just performed checking out the pull request #2442 locally, and merge. If I remember correctly, it is necessary to solve conflicts.
Then, as far as the use of attached data, it worked to the end tentatively.
However, I can't confirm that it worked correctly (because I haven't modified the code to output the calculation result).

Sky

2016年1月8日金曜日 18時43分14秒 UTC+9 Chuan Wang:

sky

unread,
Jan 9, 2016, 2:33:35 AM1/9/16
to Caffe Users
Hi, Toru

I reply here because the message has been deleted.
 

I can't hardly use either python or matlab.
So, I created the dummy data to input Caffe refer to https://github.com/BVLC/caffe/tree/master/src/caffe/test/test_data.
I want to convert my 3D data, but I can't do it due to the lack of my knowledge.
Maybe I can do refer to https://www.hdfgroup.org/HDF5/examples/intro.html, but
actually there is not enough time to concentrate using Caffe for now.

Sky

2015年12月23日水曜日 0時33分23秒 UTC+9 Toru Hironaka:

Toru Hironaka

unread,
Jan 11, 2016, 12:32:20 PM1/11/16
to Caffe Users
Hi, Sky

I posted my code previously but I found some bugs so I deleted. I am using someone's Matlab code and my python code to convert image files into hdf5. Caffe accept both hdf5 datasets but I have not gotten good results. I always got very low accuracy about 0.5 and very high loass 1.5 or even higher. I am trying to get better results now and find out my datasets' problem. Thanks for your post!!

Toru 
Reply all
Reply to author
Forward
0 new messages