-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_SDCNN_opts.m
120 lines (105 loc) · 4.01 KB
/
init_SDCNN_opts.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
function opts = init_SDCNN_opts()
% -------------------------------------------------------------------------
% Description:
% Generate model options for SDCNN
%
% Input:
% - scale : upsampling scale
% - depth : number of conv layers in one pyramid level
% - gpu : GPU ID, 0 for CPU mode
%
% Output:
% - opts : options for DsCNN
%
% Citation:
% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution
% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang
% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017
%
% Contact:
% Wei-Sheng Lai
% wlai24@ucmerced.edu
% University of California, Merced
% -------------------------------------------------------------------------
%% network options
% opts.scale = 3;
opts.depth = 4; % 网络尺度数
% opts.lc = 1; % 每个尺度层上的卷积数
opts.weight_decay = 0.0001;
opts.init_sigma = 0.001;
opts.conv_f = 3;
opts.conv_n = 64;
%opts.loss = 'L1';
% opts.loss = 'L2';
opts.loss = 'softmaxlog';
%% training options
opts.gpu = 1;
%opts.batch_size = 64;
%opts.batch_size = 32;
opts.batch_size = 10;
opts.num_train_batch = 100; % number of training batch in one epoch
opts.num_valid_batch = 100; % number of validation batch in one epoch
% opts.lr = 1e-3; % initial learning rate
opts.lr = 1e-4; % initial learning rate
opts.lr_step = 20; % number of epochs to drop learning rate
opts.lr_drop = 0.5; % learning rate drop ratio
opts.lr_min = 1e-6; % minimum learning rate
opts.patch_size = 256;
%opts.patch_size = 256;
opts.data_augmentation = 1;
opts.scale_augmentation = 1;
% opts.gclip = 1;
%% dataset options
opts.train_dataset = {};
%opts.train_dataset{end+1} = 'Train100_ISTD_Adjust';
%opts.train_dataset{end+1} = 'UCF-OIRDS-Train64';
opts.train_dataset{end+1} = 'AISD-Train412';
% opts.valid_dataset = {};
% opts.valid_dataset{end+1} = 'Test20_ISTD_Adjust';
%% setup model name
% opts.data_name = 'train';
% for i = 1:length(opts.train_dataset)
% opts.data_name = sprintf('%s_%s', opts.data_name, opts.train_dataset{i});
% end
for i = 1:length(opts.train_dataset)
opts.data_name = sprintf('%s',opts.train_dataset{i});
end
opts.net_name = sprintf('SDCNN_%s', opts.loss);
% opts.model_name = sprintf('%s_%s_pw%d_lr%s_step%d_drop%s_min%s_bs%d_depth_%d_level1_relu_improve_noselect_res_BN_U_BRC_crop_fuse', ...
% opts.net_name, ...
% opts.data_name, opts.patch_size, ...
% num2str(opts.lr), opts.lr_step, ...
% num2str(opts.lr_drop), num2str(opts.lr_min), ...
% opts.batch_size,opts.depth);
opts.model_name = sprintf('%s_%s', ...
opts.net_name, ...
opts.data_name);
%% setup dagnn training parameters
if( opts.gpu == 0 )
opts.train.gpus = [];
else
opts.train.gpus = [opts.gpu];
end
opts.train.batchSize = opts.batch_size;
% opts.train.numEpochs = 1000;
opts.train.numEpochs = 100;
opts.train.continue = true;
opts.train.learningRate = learning_rate_policy(opts.lr, opts.lr_step, opts.lr_drop, ...
opts.lr_min, opts.train.numEpochs);
opts.train.expDir = fullfile('models', opts.model_name) ; % model output dir
if( ~exist(opts.train.expDir, 'dir') )
mkdir(opts.train.expDir);
end
opts.train.model_name = opts.model_name;
opts.train.num_train_batch = opts.num_train_batch;
opts.train.num_valid_batch = opts.num_valid_batch;
% setup loss
% opts.train.derOutputs = {'loss',1};
% opts.level = ceil(log(opts.scale) / log(2));
opts.level = opts.depth;
opts.train.derOutputs = {};
for s = opts.level : -1 : 1
opts.train.derOutputs{end+1} = sprintf('level%d_BCE_loss', s);
opts.train.derOutputs{end+1} = 1;
end
end