-
Notifications
You must be signed in to change notification settings - Fork 5
/
caffe_layer_conv_def.m
78 lines (71 loc) · 1.86 KB
/
caffe_layer_conv_def.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function [ layer_str ] = caffe_layer_conv_def( name, bottom, kernel_size, num_output, add_mult, varargin)
%% Description
% Generates default Convolution layer values given layer name
% --- INPUT:
% indx = index for the layer
% --- OUTPUT:
% layer_str = structure describing a layer
%
%% Execution
%Name
if ischar(name)
layer_str.name = name;
else
layer_str.name = sprintf('conv%d', name);
end
conv_name = 'Convolution';
layer_str.type = conv_name;
% Bottom layer
layer_str.bottom = bottom;
layer_str.top = layer_str.name;
if add_mult
layer_str.param{1}.lr_mult = 1;
layer_str.param{1}.decay_mult = 1;
layer_str.param{2}.lr_mult = 2;
layer_str.param{2}.decay_mult = 0;
end
layer_str.convolution_param.num_output = num_output;
layer_str.convolution_param.kernel_size = kernel_size;
for i_param = 1:2:length(varargin)
param_name = varargin{i_param};
param_value = varargin{i_param+1};
layer_str.convolution_param.(param_name) = param_value;
if isfield(layer_str.convolution_param, 'kernel_size') && ...
(strcmp(param_name, 'kernel_h') || strcmp(param_name, 'kernel_w'))
% remove kernel field
layer_str.convolution_param = rmfield(...
layer_str.convolution_param, 'kernel_size');
end
end
layer_str.convolution_param.weight_filler.type = 'xavier';
layer_str.convolution_param.bias_filler.type = 'constant';
layer_str.convolution_param.bias_filler.value = 0;
% layer {
% name: "conv2"
% type: "Convolution"
% bottom: "pool1"
% top: "conv2"
% param {
% lr_mult: 1
% decay_mult: 1
% }
% param {
% lr_mult: 2
% decay_mult: 0
% }
% convolution_param {
% num_output: 128
% kernel_h: 1
% kernel_w: 2
% stride_h: 1
% stride_w: 1
% weight_filler {
% type: "xavier"
% }
% bias_filler {
% type: "constant"
% value: 1
% }
% }
% }
end