caffe-mt
caffe-mt copied to clipboard
error in adding locally connected layer to caffe
Hi, I want to add locally connected layer to my caffe, So I did everything that write in this link, after that I open a terminal and change directory to caffe root and try make
command but I get below error.
PROTOC src/caffe/proto/caffe.proto
NVCC src/caffe/solvers/adagrad_solver.cu
NVCC src/caffe/solvers/adam_solver.cu
caffe.proto:386:12: "LocalConvolutionParameter" is not defined.
Makefile:638: recipe for target '.build_release/src/caffe/proto/caffe.pb.cc' failed
but I'm sure that I add LocalConvolutionParameter
to my caffe.proto
!! I don't have any idea about caffe.pb.cc
and caffe.pb.h
files. My caffe.proto
file can be accessed via this link.
@robosina You should put the definition of LocalConvolutionParameter
, which is originally at line number 605
in your caffe.proto before the line it is used at, which is at line number 386
.
@knsong , I can't figured out it ,so I reinstall caffe with this fork!! thanks for your help
@robosina Did you try it as I mentioned above?
I can't did it because when I read same issue in this branch , I realized that I need to update my protobuf then when I want to update my protobuf I did a mistake and my ubuntu won't boot after that so I install ubuntu again and install your caffe.
and another issue that I have is I can't see Q&A in stackoverflow about your locally connected implementation so can you please help me where I can get answers for my question about
1- what is the locally connected parameters like local_region_number_h
,local_region_ratio_h
,local_region_step_h
,kernel_h
, I see some explanation in this link but I can't understand them very well ,so is there any tutorial to understand this parameters or can you please add some simple example like LeNet
with locally connected layers or please give me a sight to I can do it
2- I have to use locally connected which bottom layer has 16x63x63
size and I know my locally connected layer is 16 filters, 9x9
and output after locally connected is 16x55x55
so I don't know how I can set below parameters
local_region_number_h & w
local_region_ration_h & w
local_region_step_h & w
kernel_h & w
I think this must be 9 & 9 right?
@robosina sorry for answering you late.
-
local_region_number_h/w
means your setting of local region number along the height/width axis.local_region_ratio_h/w
sets the ratio of height/width of local regions to height/width of the input feature map.local_region_step_h
sets the intervals of successive local regions, e.g. iflocal_region_step_h == 2
, and you have 2x2 local regions, then the first local region's left-top corner is at (0, 0), and the third's is at (2, 0). - In this case, you can choose
local_region_number_h & w == 5, local_region_ratio_h & w == 19 / 63, local_region_step_h & w == 9(which is (55 - 19) / 2 / 2 )
.
Thanks @knsong , before you answer my question I wrote a layer like below and I check the size of output in python and it seems that output size is OK , please see my layer ! what I miss if I wrote a layer like below
layer {
name: "L4"
type: "LocalConvolution"
bottom: "C3" # input size is 63x63
top: "L4"
local_conv_param {
num_output: 16
kernel_h: 9
kernel_w: 9
stride: 1
pad: 0
}
}
I get output size 55x55
and my next question is how you choose local_region_number_h==5 , and number 19 :(
@robosina In this case, the parameters' value for local convolution will be the default ones, namely local_region_number_h & w == 1
, so it degrades to a normal convolution. Because using the recommend settings above, each local convolution will get a 11x11
output, so local_region_number_h & w == 5
will ensure the entire output spatial size will be 55x55
.
@knsong Thanks but I guess I can't imagine layer very well and I must think about this later precisely but for my last question when we use ordinary convolution we have a formula to calculate output size:
output size=(N-k+2*p)/S + 1
where in this formula N:input size
,k=kernel size
,p=padding
and S=stride
is there any similar formula between locallyConvolution
parameters?
Thanks
@robosina For locallyConvolution
layer, output size = ((NL - k + 2 * p) / S + 1) * local_region_num_h/w
, in which NL
is input local region size(height or width) and NL = floor(input_size * local_region_ratio_h/w)
.
@knsong Thank you very much