forked from kyunghyuncho/deepmat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault_dbm.m
104 lines (90 loc) · 3.06 KB
/
default_dbm.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
% default_dbm -
% Copyright (C) 2011 KyungHyun Cho, Tapani Raiko, Alexander Ilin
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%
function [D] = default_dbm (layers)
% data type
D.data.binary = 1;
%D.data.binary = 0; % for GDBM
% learning parameters
D.learning.cd_k = 1;
D.learning.persistent_cd = 0;
D.learning.lrate = 1e-3;
D.learning.lrate0 = 5000;
D.learning.momentum = 0;
D.learning.weight_decay = 0;
D.learning.minibatch_sz = 100;
D.learning.lrate_anneal = 0.9;
D.enhanced_grad.use = 1;
% adaptive learning rate
D.adaptive_lrate.use = 1;
D.adaptive_lrate.max_iter_up = 1;
D.adaptive_lrate.max_iter_down = 1;
D.adaptive_lrate.exp_up = 1.01;
D.adaptive_lrate.exp_down = 0.99;
D.adaptive_lrate.lrate_ub = Inf;
D.adaptive_lrate.lrate_lb = -Inf;
% Gaussian-Bernoulli RBM
D.grbm.do_vsample = 1;
D.grbm.do_normalize = 1;
D.grbm.do_normalize_std = 1;
D.grbm.learn_sigmas = 1;
D.grbm.sigmas_ub = Inf;
D.grbm.use_single_sigma = 1;
D.mf.reg = 0;
% stopping criterion
% if you happen to know some other criteria, please, do add them.
% if the criterion is zero, it won't stop unless the whole training epochs were consumed.
D.stop.criterion = 0;
% criterion == 1
D.stop.recon_error.tolerate_count = 1000;
% criterion == 2
D.stop.lrate.lowlrate_threshold = 1e-8;
% structure
n_layers = length(layers);
D.structure.layers = layers;
% initializations
D.W = cell(n_layers, 1);
D.biases = cell(n_layers, 1);
D.sigmas = ones(layers(1), 1);
for l = 1:n_layers
D.biases{l} = zeros(layers(l), 1);
if l < n_layers
D.W{l} = 1/sqrt(layers(l)+layers(l+1)) * randn(layers(l), layers(l+1));
end
end
D.centering.use = 0;
D.centering.centers = cell(n_layers, 1);
for l = 1:n_layers
D.centering.centers{l} = sigmoid(D.biases{l});
end
% iteration
D.iteration.n_epochs = 100;
D.iteration.n_updates = 0;
% learning signals
D.signals.recon_errors = [];
D.signals.lrates = [];
D.signals.momentums = [];
D.signals.n_epochs = 0;
% debug
D.verbose = 0;
D.debug.do_display = 0;
D.debug.display_interval = 10;
D.debug.display_fid = 1;
D.debug.display_function = @visualize_dbm;
% hook
D.hook.per_epoch = {@save_intermediate, {'dbm.mat'}};
D.hook.per_update = {@print_n_updates, {}};