Instead of having a learnable filter, I am interested in a convolution with a fix predefined matrix; for example sobel filter:
so, I set learning = 0 (so its fixed), and my kernel size = 3 as:
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param { lr_mult: 0 decay_mult: 0 }
convolution_param {
num_output: 10
kernel_size: 3 # filter is 3x3
stride: 2
weight_filler {
type: ??}
}
}
Now, I do not know how to give matrix information to the conv layer. Any ideas? I think it should go to weight_filler, but how?
One more question: num_output has to be same as bottom's (data channel = 10 here) channel size? can I set num_output another number? if yes, what will happen and what that means?
You can use net_surgery
to load your untrained/un-initialized net in python and then assign the specific weights you want to the filters, save the net, and use it with the weights you want for this specific layer.
num_output
and other conv_params
?This is a good question: You have an input blob of shape b
x10
xh
xw
and you want to apply a 3
x3
filter to each channel and get back a new filtered b
x10
xh
xw
. If you just set num_output: 10
, the shape of the filters would be 10
x10
x3
x3
, that is, 10 filters of shape 10
x3
x3
- which is not want you expect. You want a 3
x3
filter.
To that end you need to look at group
conv_param. Setting group: 10
together with num_output: 10
(assuming input c=10) will give you what you want, the weight shape will be 10
x1
x3
x3
.