forked from tsungyu/o2dp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_experiments.m
171 lines (148 loc) · 4.15 KB
/
run_experiments.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
function run_experiments()
% Copyright (C) 2015 Tsung-Yu Lin, Aruni RoyChowdhury, Subhransu Maji.
% All rights reserved.
%
% This file is part of the BCNN and is made available under
% the terms of the BSD license (see the COPYING file).
% This code is used for testing different encoding schemes with svm
%% fully connected pooling
rcnn.name = 'rcnn' ;
rcnn.opts = {...
'type', 'rcnn', ...
'model', 'data/models/imagenet-vgg-m.mat', ...
'layer', 19} ;
rcnnvd.name = 'rcnnvd' ;
rcnnvd.opts = {...
'type', 'rcnn', ...
'model', 'data/models/imagenet-vgg-verydeep-16.mat', ...
'layer', 35} ;
%% fisher vector CNN
dcnn.name = 'dcnn' ;
dcnn.opts = {...
'type', 'dcnn', ...
'model', 'data/models/imagenet-vgg-m.mat', ...
'layer', 14, ...
'numWords', 64} ;
dcnnvd.name = 'dcnnvd' ;
dcnnvd.opts = {...
'type', 'dcnn', ...
'model', 'data/models/imagenet-vgg-verydeep-16.mat', ...
'layer', 30, ...
'numWords', 64} ;
%% fisher vector SIFT
dsift.name = 'dsift' ;
dsift.opts = {...
'type', 'dsift', ...
'numWords', 256, ...
'numPcaDimensions', 80} ;
%% bilinear pooling CNN
bcnnmm.name = 'bcnnmm' ;
bcnnmm.opts = {...
'type', 'bcnn', ...
'modela', 'data/models/imagenet-vgg-m.mat', ...
'layera', 14,...
'modelb', [], ... % set to empty when use two identical networks
'layerb', 14
} ;
bcnnvdm.name = 'bcnnvdm' ;
bcnnvdm.opts = {...
'type', 'bcnn', ...
'modela', 'data/models/imagenet-vgg-verydeep-16.mat', ...
'layera', 30,...
'modelb', 'data/models/imagenet-vgg-m.mat', ...
'layerb', 14
} ;
bcnnvdvd.name = 'bcnnvdvd' ;
bcnnvdvd.opts = {...
'type', 'bcnn', ...
'modela', 'data/models/imagenet-vgg-verydeep-16.mat', ...
'layera', 30,...
'modelb', [], ...
'layerb', 30,...
};
%% fine-tuned bilinear pooling CNN
% set other than modela to empty if your network has bilinear pooling
% layers
bcnnmmft.name = 'bcnnmmft' ;
bcnnmmft.opts = {...
'type', 'bcnn', ...
'modela', 'data/ft_models/bcnn-cub-mm-net.mat', ...
'layera', [],...
'modelb', [], ...
'layerb', []
} ;
bcnnvdmft.name = 'bcnnvdmft' ;
bcnnvdmft.opts = {...
'type', 'bcnn', ...
'modela', 'data/ft_models/bcnn-cub-dm.mat', ...
'layera', [],...
'modelb', [], ...
'layerb', []
} ;
bcnnvdvdft.name = 'bcnnvdvdft' ;
bcnnvdvdft.opts = {...
'type', 'bcnn', ...
'modela', 'data/ft_models/bcnn-cub-dd.mat', ...
'layera', [],...
'modelb', [], ...
'layerb', [],...
};
%% imporved bilinear CNNs
impbcnnm.name = 'impbcnnm' ;
impbcnnm.opts = {...
'type', 'impbcnn', ...
'model', 'data/models/imagenet-vgg-m.mat', ...
'layer', 14, ...
'pow', 0.5, ...
'sigma', 1, ...
'method', 'schulz', ...
'bpMethod', 'lyap', ...
'maxIter', 5, ...
} ;
impbcnnvd.name = 'impbcnnvd' ;
impbcnnvd.opts = {...
'type', 'impbcnn', ...
'model', 'data/models/imagenet-vgg-verydeep-16.mat', ...
'layer', 30,...
'pow', 0.5, ...
'sigma', 1, ...
'method', 'schulz', ...
'bpMethod', 'layp', ...
'maxIter', 5, ...
} ;
setupNameList = {'impbcnnm'}; % list of models to train and test
encoderList = {{impbcnnm}};
datasetList = {{'cub', 1}};
scales = [2];
for ii = 1 : numel(datasetList)
dataset = datasetList{ii} ;
if iscell(dataset)
numSplits = dataset{2} ;
dataset = dataset{1} ;
else
numSplits = 1 ;
end
switch dataset
case {'cub', 'cars'}
border = [0, 00];
case 'aircraft-variant'
border = [32, 32];
end
for jj = 1 : numSplits
for ee = 1: numel(encoderList)
% train and test the model
model_train(...
'dataset', dataset, ...
'seed', jj, ...
'encoders', encoderList{ee}, ...
'prefix', 'impbcnnm', ... % name of the output folder
'suffix', setupNameList{ee}, ...
'printDatasetInfo', ee == 1, ...
'useGpu', 4, ...
'imgScale', scales(ee), ...
'dataAugmentation', 'f1', ...
'border', border) ;
end
end
end
end