-
Notifications
You must be signed in to change notification settings - Fork 2
/
ltmlp_demo3.m
78 lines (68 loc) · 3.12 KB
/
ltmlp_demo3.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
%% This demo replicates results in [1], Section 5, MNIST classification
% load zero-mean MNIST data
load('data/mnist_preprocessed.mat');
% Network size 784-800-800-10
nl = [800 800];
nltypes = {'tanh', 'tanh', 'softmax'};
%% Network with all three transformations
% random number generator seed
rng(9291);
options = ltmlp_opt('stepsize', 0.2, 'runtime', 150, 'weightdecay', 0., ...
'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
'numtransf', 3, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
'ratedecay', 0.9);
net = ltmlp(nl, nltypes, 784, 10);
net = ltmlp_init(net, options, data_input);
[~, res1] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%% Network without gamma (only two transformations)
rng(9291);
options = ltmlp_opt('stepsize', 0.7, 'runtime', 150, 'weightdecay', 0., ...
'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
'numtransf', 2, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
'ratedecay', 0.9);
net = ltmlp(nl, nltypes, 784, 10);
net = ltmlp_init(net, options, data_input);
[~, res2] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%% Network without transformations
rng(9291);
options = ltmlp_opt('stepsize', 0.05, 'runtime', 150, 'weightdecay', 0., ...
'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
'numtransf', 0, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
'ratedecay', 0.9);
net = ltmlp(nl, nltypes, 784, 10);
net = ltmlp_init(net, options, data_input);
[~, res3] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%% Three-layer networks
%
% nl = [400 400 400];
% nltypes = {'tanh', 'tanh', 'tanh', 'softmax'};
%
% rng(9291);
% options = ltmlp_opt('stepsize', 0.3, 'runtime', 150, 'weightdecay', 0., ...
% 'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
% 'numtransf', 3, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
% 'ratedecay', 0.9);
% net = ltmlp(nl, nltypes, 784, 10);
% net = ltmlp_init(net, options, data_input);
% [~, res1_big] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%
%
% rng(9291);
% options = ltmlp_opt('stepsize', 0.7, 'runtime', 150, 'weightdecay', 0., ...
% 'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
% 'numtransf', 2, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
% 'ratedecay', 0.9);
% net = ltmlp(nl, nltypes, 784, 10);
% net = ltmlp_init(net, options, data_input);
% [~, res2_big] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%
% rng(9291);
% options = ltmlp_opt('stepsize', 0.05, 'runtime', 150, 'weightdecay', 0., ...
% 'inputnoise', 0.3, 'task', 'classification', 'verbose', 1, ...
% 'numtransf', 0, 'batchsize', 1000, 'mominit', 0.5, 'momentum', 0.9, 'burnin', 50, ...
% 'ratedecay', 0.9);
% net = ltmlp(nl, nltypes, 784, 10);
% net = ltmlp_init(net, options, data_input);
% [~, res3_big] = ltmlp_train2(net, data_input, data_output, valid_input, valid_output);
%
% save('comfirm_results', 'res1', 'res2', 'res3', 'res1_big', 'res2_big', 'res3_big')