-
Notifications
You must be signed in to change notification settings - Fork 17
/
demnlab.m
380 lines (325 loc) · 9.28 KB
/
demnlab.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
function demnlab(action);
%DEMNLAB A front-end Graphical User Interface to the demos
%
% Description
% This function will start a user interface allowing the user to select
% different demonstration functions to view. The demos are divided into
% 4 groups, with the demo being executed by selecting the desired
% option from a pop-up menu.
%
% See also
%
% Copyright (c) Ian T Nabney (1996-2001)
% If run without parameters, initialise gui.
if nargin<1,
action='initialise';
end;
if strcmp(action,'initialise'),
% Create figure
fig = figure( ...
'Name', 'Netlab Demos', ...
'NumberTitle', 'off', ...
'Color', [0.7529 0.7529 0.7529], ...
'Visible', 'on');
% Create GROUPS
% Bottom of demo buttons
group1_bot = 0.20;
group1_top = 0.75;
uicontrol(fig, ...
'Style', 'frame', ...
'Units', 'normalized', ...
'Position', [0.03 group1_bot 0.94 group1_top - group1_bot], ...
'BackgroundColor', [0.5 0.5 0.5]);
% Bottom of help and close buttons
group2_bot = 0.04;
uicontrol(fig, ...
'Style', 'frame', ...
'Units', 'normalized', ...
'Position', [0.03 group2_bot 0.94 0.12], ...
'BackgroundColor', [0.5 0.5 0.5]);
% Draw title
hLogoAxis = axes( ...
'Units', 'normalized', ...
'Position', [0.05 0.82 0.90 0.14], ...
'Box', 'off', ...
'XColor', [0 0 0], ...
'YColor', [0 0 0], ...
'Visible', 'on');
load netlogo; % load image and colour map
colormap(netcmap(1:3,:)); % change colour map: don't need many entries
image(nlogo); % draw logo
axis('image'); % ensures pixels on axis are square
axis off; % turn axes off
% Create static text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.05 group1_top-0.1 0.90 0.08], ...
'String', 'Select demo to run:');
% First row text offset
tRow1Offset = 0.14;
% Offset between text and button
TBoffset = 0.07;
% First row button offset
bRow1Offset = tRow1Offset+TBoffset;
% ONE text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.08 group1_top-tRow1Offset 0.36 0.05], ...
'String', 'Regression');
popup1str(1) = {'Select Option'};
popup1str(2) = {'Multi-Layer Perceptron'};
popup1str(3) = {'Radial Basis Function'};
popup1str(4) = {'Mixture Density Network'};
% ONE popup
hPop1 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String', popup1str, ...
'Position', [0.08 group1_top-bRow1Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup1');
% TWO text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.56 group1_top-tRow1Offset 0.36 0.05], ...
'String', 'Classification');
popup2str(1) = popup1str(1);
popup2str(2) = {'Generalised Linear Model (2 class)'};
popup2str(3) = {'Generalised Linear Model (3 class)'};
popup2str(4) = {'Multi-Layer Perceptron'};
popup2str(5) = {'K nearest neighbour'};
% TWO popup
hPop2 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String', popup2str, ...
'Position', [0.56 group1_top-bRow1Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup2');
tRow2Offset = 0.30;
bRow2Offset = tRow2Offset+TBoffset;
% THREE text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.08 group1_top - tRow2Offset 0.36 0.05], ...
'String', 'Density Modelling and Clustering');
popup3str(1) = popup1str(1);
popup3str(2) = {'Gaussian Mixture (EM training)'};
popup3str(3) = {'Gaussian Mixture (spherical)'};
popup3str(4) = {'Gaussian Mixture (diagonal)'};
popup3str(5) = {'Gaussian Mixture (full)'};
popup3str(6) = {'Neuroscale'};
popup3str(7) = {'GTM (EM training)'};
popup3str(8) = {'GTM (visualisation)'};
popup3str(9) = {'K-means clustering'};
popup3str(10) = {'Self-Organising Map'};
% TWO popup
% THREE popup
hPop3 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String', popup3str, ...
'Position', [0.08 group1_top - bRow2Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup3');
% FOUR text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.56 group1_top - tRow2Offset 0.36 0.05], ...
'String', 'Bayesian Methods');
popup4str(1) = popup1str(1);
popup4str(2) = {'Sampling the MLP Prior'};
popup4str(3) = {'Evidence Approximation for MLP'};
popup4str(4) = {'Evidence Approximation for RBF'};
popup4str(5) = {'Evidence Approximation in Classification'};
popup4str(6) = {'ARD for MLP'};
popup4str(7) = {'Sampling the GP Prior'};
popup4str(8) = {'GPs for Regression'};
popup4str(9) = {'ARD for GP'};
% FOUR popup
hPop4 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String', popup4str, ...
'Position', [0.56 group1_top - bRow2Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup4');
tRow3Offset = 0.45;
bRow3Offset = tRow3Offset+TBoffset;
% FIVE text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.08 group1_top - tRow3Offset 0.36 0.05], ...
'String', 'Optimisation and Visualisation');
popup5str(1) = popup1str(1);
popup5str(2) = {'Algorithm Comparison'};
popup5str(3) = {'On-line Gradient Descent'};
popup5str(4) = {'Hinton Diagrams'};
% FIVE popup
hPop5 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String',popup5str, ...
'Position', [0.08 group1_top - bRow3Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup5');
% SIX text
uicontrol(fig, ...
'Style', 'text', ...
'Units', 'normalized', ...
'BackgroundColor', [0.5 0.5 0.5], ...
'Position', [0.56 group1_top - tRow3Offset 0.36 0.05], ...
'String', 'Sampling');
popup6str(1) = popup1str(1);
popup6str(2) = {'Sampling a Gaussian'};
popup6str(3) = {'MCMC sampling (Metropolis)'};
popup6str(4) = {'Hybrid MC (Gaussian mixture)'};
popup6str(5) = {'Hybrid MC for MLP I'};
popup6str(6) = {'Hybrid MC for MLP II'};
% SIX popup
hPop6 = uicontrol(fig, ...
'Style','popup', ...
'Units','normalized', ...
'String', popup6str, ...
'Position', [0.56 group1_top - bRow3Offset 0.36 0.08], ...
'BackgroundColor', [0.7 0.7 0.7], ...
'Callback', 'demnlab popup6');
% Create HELP button
uicontrol(fig, ...
'Units', 'normalized', ...
'Position' , [0.05 group2_bot+0.02 0.40 0.08], ...
'String', 'Help', ...
'Callback', 'demnlab help');
% Create CLOSE button
uicontrol(fig, ...
'Units', 'normalized', ...
'Position' , [0.55 group2_bot+0.02 0.40 0.08], ...
'String', 'Close', ...
'Callback', 'close(gcf)');
hndlList=[fig hPop1 hPop2 hPop3 hPop4 hPop5 hPop6];
set(fig, 'UserData', hndlList);
set(fig, 'HandleVisibility', 'callback');
elseif strcmp(action, 'popup1'),
hndlList=get(gcf,'UserData');
hPop = hndlList(2);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demmlp1;
case 3
demrbf1;
case 4
demmdn1;
end;
elseif strcmp(action,'popup2'),
hndlList=get(gcf,'UserData');
hPop = hndlList(3);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demglm1;
case 3
demglm2;
case 4
demmlp2;
case 5
demknn1;
end
elseif strcmp(action,'popup3'),
hndlList=get(gcf,'UserData');
hPop = hndlList(4);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demgmm1;
case 3
demgmm2;
case 4
demgmm3;
case 5
demgmm4;
case 6
demns1;
case 7
demgtm1;
case 8
demgtm2;
case 9
demkmn1;
case 10
demsom1;
end
elseif strcmp(action,'popup4'),
hndlList=get(gcf,'UserData');
hPop = hndlList(5);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demprior;
case 3
demev1;
case 4
demev3;
case 5
demev2;
case 6
demard;
case 7
demprgp;
case 8
demgp;
case 9
demgpard;
end
elseif strcmp(action,'popup5'),
hndlList=get(gcf,'UserData');
hPop = hndlList(6);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demopt1;
case 3
demolgd1;
case 4
demhint;
end
elseif strcmp(action,'popup6'),
hndlList=get(gcf,'UserData');
hPop = hndlList(7);
selected = get(hPop, 'Val');
set(hPop, 'Val', [1]);
switch selected
case 2
demgauss;
case 3
demmet1;
case 4
demhmc1;
case 5
demhmc2;
case 6
demhmc3;
end
elseif strcmp(action, 'help'),
helpStr = {'To run a demo, press the appropriate button.'; ...
'Instructions and information will appear in the Matlab';...
'command window.'};
hHelpDlg = helpdlg(helpStr, 'Netlab Demo Help');
end;