-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcnn_cifar_init.m
executable file
·84 lines (73 loc) · 3.51 KB
/
cnn_cifar_init.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
function net = cnn_cifar_init(opts)
lr = [.1 2] ;
% Define network CIFAR10-quick
net.layers = {} ;
% Block 1
net.layers{end+1} = struct('type', 'conv', ...
'weights', {{0.01*randn(5,5,3,32, 'single'), zeros(1, 32, 'single')}}, ...
'learningRate', lr, ...
'stride', 1, ...
'pad', 2) ;
net.layers{end+1} = struct('type', 'pool', ...
'method', 'max', ...
'pool', [3 3], ...
'stride', 2, ...
'pad', [0 1 0 1]) ;
net.layers{end+1} = struct('type', 'relu') ;
% Block 2
net.layers{end+1} = struct('type', 'conv', ...
'weights', {{0.05*randn(5,5,32,32, 'single'), zeros(1,32,'single')}}, ...
'learningRate', lr, ...
'stride', 1, ...
'pad', 2) ;
net.layers{end+1} = struct('type', 'relu') ;
net.layers{end+1} = struct('type', 'pool', ...
'method', 'avg', ...
'pool', [3 3], ...
'stride', 2, ...
'pad', [0 1 0 1]) ; % Emulate caffe
% Block 3
% net.layers{end+1} = struct('type', 'conv', ...
% 'weights', {{0.05*randn(5,5,32,64, 'single'), zeros(1,64,'single')}}, ...
% 'learningRate', lr, ...
% 'stride', 1, ...
% 'pad', 2) ;
% net.layers{end+1} = struct('type', 'relu') ;
% net.layers{end+1} = struct('type', 'pool', ...
% 'method', 'avg', ...
% 'pool', [3 3], ...
% 'stride', 2, ...
% 'pad', [0 1 0 1]) ; % Emulate caffe
% Block 4
% net.layers{end+1} = struct('type', 'conv', ...
% 'weights', {{0.05*randn(4,4,64,64, 'single'), zeros(1,64,'single')}}, ...
% 'learningRate', lr, ...
% 'stride', 1, ...
% 'pad', 0) ;
% net.layers{end+1} = struct('type', 'relu') ;
% Original Block 5
% net.layers{end+1} = struct('type', 'conv', ...
% 'weights', {{0.05*randn(1,1,64,10, 'single'), zeros(1,10,'single')}}, ...
% 'learningRate', .1*lr, ...
% 'stride', 1, ...
% 'pad', 0) ;
% Block 5 for Block 1
% net.layers{end+1} = struct('type', 'conv', ...
% 'weights', {{0.01*randn(16,16,32,10, 'single'), zeros(1,10,'single')}}, ...
% 'learningRate', 0.001*lr, ...
% 'stride', 1, ...
% 'pad', 0) ;
% Block 5 for Block 2
net.layers{end+1} = struct('type', 'conv', ...
'weights', {{0.01*randn(8,8,32,10, 'single'), zeros(1,10,'single')}}, ...
'learningRate', .1*lr, ...
'stride', 1, ...
'pad', 0) ;
% Block 5 for Block 3
% net.layers{end+1} = struct('type', 'conv', ...
% 'weights', {{0.01*randn(4,4,64,10, 'single'), zeros(1,10,'single')}}, ...
% 'learningRate', .1*lr, ...
% 'stride', 1, ...
% 'pad', 0) ;
% Loss layer
net.layers{end+1} = struct('type', 'softmaxloss') ;