-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcnn_cifar_init.m
64 lines (56 loc) · 2.59 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
function net = cnn_cifar_init(opts)
lr = [.1 2] ;
percentN = 4 ;
% 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', 'mixlu', 'percentNeg',percentN) ;
% 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', 'mixlu', 'percentNeg', percentN) ;
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', 'mixlu', 'percentNeg', percentN) ;
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', 'mixlu', 'percentNeg', percentN) ;
% 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) ;
% Loss layer
net.layers{end+1} = struct('type', 'softmaxloss') ;