annotate toolboxes/FullBNT-1.0.7/netlab3.3/demnlab.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function demnlab(action);
Daniel@0 2 %DEMNLAB A front-end Graphical User Interface to the demos
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % This function will start a user interface allowing the user to select
Daniel@0 6 % different demonstration functions to view. The demos are divided into
Daniel@0 7 % 4 groups, with the demo being executed by selecting the desired
Daniel@0 8 % option from a pop-up menu.
Daniel@0 9 %
Daniel@0 10 % See also
Daniel@0 11 %
Daniel@0 12
Daniel@0 13 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 14
Daniel@0 15 % If run without parameters, initialise gui.
Daniel@0 16 if nargin<1,
Daniel@0 17 action='initialise';
Daniel@0 18 end;
Daniel@0 19
Daniel@0 20 if strcmp(action,'initialise'),
Daniel@0 21
Daniel@0 22 % Create figure
Daniel@0 23 fig = figure( ...
Daniel@0 24 'Name', 'Netlab Demos', ...
Daniel@0 25 'NumberTitle', 'off', ...
Daniel@0 26 'Color', [0.7529 0.7529 0.7529], ...
Daniel@0 27 'Visible', 'on');
Daniel@0 28
Daniel@0 29 % Create GROUPS
Daniel@0 30 % Bottom of demo buttons
Daniel@0 31 group1_bot = 0.20;
Daniel@0 32 group1_top = 0.75;
Daniel@0 33 uicontrol(fig, ...
Daniel@0 34 'Style', 'frame', ...
Daniel@0 35 'Units', 'normalized', ...
Daniel@0 36 'Position', [0.03 group1_bot 0.94 group1_top - group1_bot], ...
Daniel@0 37 'BackgroundColor', [0.5 0.5 0.5]);
Daniel@0 38
Daniel@0 39 % Bottom of help and close buttons
Daniel@0 40 group2_bot = 0.04;
Daniel@0 41 uicontrol(fig, ...
Daniel@0 42 'Style', 'frame', ...
Daniel@0 43 'Units', 'normalized', ...
Daniel@0 44 'Position', [0.03 group2_bot 0.94 0.12], ...
Daniel@0 45 'BackgroundColor', [0.5 0.5 0.5]);
Daniel@0 46
Daniel@0 47 % Draw title
Daniel@0 48 hLogoAxis = axes( ...
Daniel@0 49 'Units', 'normalized', ...
Daniel@0 50 'Position', [0.05 0.82 0.90 0.14], ...
Daniel@0 51 'Box', 'off', ...
Daniel@0 52 'XColor', [0 0 0], ...
Daniel@0 53 'YColor', [0 0 0], ...
Daniel@0 54 'Visible', 'on');
Daniel@0 55
Daniel@0 56 load netlogo; % load image and colour map
Daniel@0 57 colormap(netcmap(1:3,:)); % change colour map: don't need many entries
Daniel@0 58 image(nlogo); % draw logo
Daniel@0 59 axis('image'); % ensures pixels on axis are square
Daniel@0 60 axis off; % turn axes off
Daniel@0 61
Daniel@0 62 % Create static text
Daniel@0 63 uicontrol(fig, ...
Daniel@0 64 'Style', 'text', ...
Daniel@0 65 'Units', 'normalized', ...
Daniel@0 66 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 67 'Position', [0.05 group1_top-0.1 0.90 0.08], ...
Daniel@0 68 'String', 'Select demo to run:');
Daniel@0 69
Daniel@0 70 % First row text offset
Daniel@0 71 tRow1Offset = 0.14;
Daniel@0 72 % Offset between text and button
Daniel@0 73 TBoffset = 0.07;
Daniel@0 74 % First row button offset
Daniel@0 75 bRow1Offset = tRow1Offset+TBoffset;
Daniel@0 76 % ONE text
Daniel@0 77 uicontrol(fig, ...
Daniel@0 78 'Style', 'text', ...
Daniel@0 79 'Units', 'normalized', ...
Daniel@0 80 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 81 'Position', [0.08 group1_top-tRow1Offset 0.36 0.05], ...
Daniel@0 82 'String', 'Regression');
Daniel@0 83
Daniel@0 84 popup1str(1) = {'Select Option'};
Daniel@0 85 popup1str(2) = {'Multi-Layer Perceptron'};
Daniel@0 86 popup1str(3) = {'Radial Basis Function'};
Daniel@0 87 popup1str(4) = {'Mixture Density Network'};
Daniel@0 88 % ONE popup
Daniel@0 89 hPop1 = uicontrol(fig, ...
Daniel@0 90 'Style','popup', ...
Daniel@0 91 'Units','normalized', ...
Daniel@0 92 'String', popup1str, ...
Daniel@0 93 'Position', [0.08 group1_top-bRow1Offset 0.36 0.08], ...
Daniel@0 94 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 95 'Callback', 'demnlab popup1');
Daniel@0 96
Daniel@0 97 % TWO text
Daniel@0 98 uicontrol(fig, ...
Daniel@0 99 'Style', 'text', ...
Daniel@0 100 'Units', 'normalized', ...
Daniel@0 101 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 102 'Position', [0.56 group1_top-tRow1Offset 0.36 0.05], ...
Daniel@0 103 'String', 'Classification');
Daniel@0 104
Daniel@0 105 popup2str(1) = popup1str(1);
Daniel@0 106 popup2str(2) = {'Generalised Linear Model (2 class)'};
Daniel@0 107 popup2str(3) = {'Generalised Linear Model (3 class)'};
Daniel@0 108 popup2str(4) = {'Multi-Layer Perceptron'};
Daniel@0 109 popup2str(5) = {'K nearest neighbour'};
Daniel@0 110 % TWO popup
Daniel@0 111 hPop2 = uicontrol(fig, ...
Daniel@0 112 'Style','popup', ...
Daniel@0 113 'Units','normalized', ...
Daniel@0 114 'String', popup2str, ...
Daniel@0 115 'Position', [0.56 group1_top-bRow1Offset 0.36 0.08], ...
Daniel@0 116 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 117 'Callback', 'demnlab popup2');
Daniel@0 118
Daniel@0 119 tRow2Offset = 0.30;
Daniel@0 120 bRow2Offset = tRow2Offset+TBoffset;
Daniel@0 121 % THREE text
Daniel@0 122 uicontrol(fig, ...
Daniel@0 123 'Style', 'text', ...
Daniel@0 124 'Units', 'normalized', ...
Daniel@0 125 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 126 'Position', [0.08 group1_top - tRow2Offset 0.36 0.05], ...
Daniel@0 127 'String', 'Density Modelling and Clustering');
Daniel@0 128
Daniel@0 129 popup3str(1) = popup1str(1);
Daniel@0 130 popup3str(2) = {'Gaussian Mixture (EM training)'};
Daniel@0 131 popup3str(3) = {'Gaussian Mixture (spherical)'};
Daniel@0 132 popup3str(4) = {'Gaussian Mixture (diagonal)'};
Daniel@0 133 popup3str(5) = {'Gaussian Mixture (full)'};
Daniel@0 134 popup3str(6) = {'Neuroscale'};
Daniel@0 135 popup3str(7) = {'GTM (EM training)'};
Daniel@0 136 popup3str(8) = {'GTM (visualisation)'};
Daniel@0 137 popup3str(9) = {'K-means clustering'};
Daniel@0 138 popup3str(10) = {'Self-Organising Map'};
Daniel@0 139 % TWO popup
Daniel@0 140 % THREE popup
Daniel@0 141 hPop3 = uicontrol(fig, ...
Daniel@0 142 'Style','popup', ...
Daniel@0 143 'Units','normalized', ...
Daniel@0 144 'String', popup3str, ...
Daniel@0 145 'Position', [0.08 group1_top - bRow2Offset 0.36 0.08], ...
Daniel@0 146 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 147 'Callback', 'demnlab popup3');
Daniel@0 148
Daniel@0 149 % FOUR text
Daniel@0 150 uicontrol(fig, ...
Daniel@0 151 'Style', 'text', ...
Daniel@0 152 'Units', 'normalized', ...
Daniel@0 153 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 154 'Position', [0.56 group1_top - tRow2Offset 0.36 0.05], ...
Daniel@0 155 'String', 'Bayesian Methods');
Daniel@0 156
Daniel@0 157 popup4str(1) = popup1str(1);
Daniel@0 158 popup4str(2) = {'Sampling the MLP Prior'};
Daniel@0 159 popup4str(3) = {'Evidence Approximation for MLP'};
Daniel@0 160 popup4str(4) = {'Evidence Approximation for RBF'};
Daniel@0 161 popup4str(5) = {'Evidence Approximation in Classification'};
Daniel@0 162 popup4str(6) = {'ARD for MLP'};
Daniel@0 163 popup4str(7) = {'Sampling the GP Prior'};
Daniel@0 164 popup4str(8) = {'GPs for Regression'};
Daniel@0 165 popup4str(9) = {'ARD for GP'};
Daniel@0 166 % FOUR popup
Daniel@0 167 hPop4 = uicontrol(fig, ...
Daniel@0 168 'Style','popup', ...
Daniel@0 169 'Units','normalized', ...
Daniel@0 170 'String', popup4str, ...
Daniel@0 171 'Position', [0.56 group1_top - bRow2Offset 0.36 0.08], ...
Daniel@0 172 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 173 'Callback', 'demnlab popup4');
Daniel@0 174
Daniel@0 175
Daniel@0 176 tRow3Offset = 0.45;
Daniel@0 177 bRow3Offset = tRow3Offset+TBoffset;
Daniel@0 178 % FIVE text
Daniel@0 179 uicontrol(fig, ...
Daniel@0 180 'Style', 'text', ...
Daniel@0 181 'Units', 'normalized', ...
Daniel@0 182 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 183 'Position', [0.08 group1_top - tRow3Offset 0.36 0.05], ...
Daniel@0 184 'String', 'Optimisation and Visualisation');
Daniel@0 185
Daniel@0 186 popup5str(1) = popup1str(1);
Daniel@0 187 popup5str(2) = {'Algorithm Comparison'};
Daniel@0 188 popup5str(3) = {'On-line Gradient Descent'};
Daniel@0 189 popup5str(4) = {'Hinton Diagrams'};
Daniel@0 190 % FIVE popup
Daniel@0 191 hPop5 = uicontrol(fig, ...
Daniel@0 192 'Style','popup', ...
Daniel@0 193 'Units','normalized', ...
Daniel@0 194 'String',popup5str, ...
Daniel@0 195 'Position', [0.08 group1_top - bRow3Offset 0.36 0.08], ...
Daniel@0 196 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 197 'Callback', 'demnlab popup5');
Daniel@0 198
Daniel@0 199 % SIX text
Daniel@0 200 uicontrol(fig, ...
Daniel@0 201 'Style', 'text', ...
Daniel@0 202 'Units', 'normalized', ...
Daniel@0 203 'BackgroundColor', [0.5 0.5 0.5], ...
Daniel@0 204 'Position', [0.56 group1_top - tRow3Offset 0.36 0.05], ...
Daniel@0 205 'String', 'Sampling');
Daniel@0 206
Daniel@0 207 popup6str(1) = popup1str(1);
Daniel@0 208 popup6str(2) = {'Sampling a Gaussian'};
Daniel@0 209 popup6str(3) = {'MCMC sampling (Metropolis)'};
Daniel@0 210 popup6str(4) = {'Hybrid MC (Gaussian mixture)'};
Daniel@0 211 popup6str(5) = {'Hybrid MC for MLP I'};
Daniel@0 212 popup6str(6) = {'Hybrid MC for MLP II'};
Daniel@0 213 % SIX popup
Daniel@0 214 hPop6 = uicontrol(fig, ...
Daniel@0 215 'Style','popup', ...
Daniel@0 216 'Units','normalized', ...
Daniel@0 217 'String', popup6str, ...
Daniel@0 218 'Position', [0.56 group1_top - bRow3Offset 0.36 0.08], ...
Daniel@0 219 'BackgroundColor', [0.7 0.7 0.7], ...
Daniel@0 220 'Callback', 'demnlab popup6');
Daniel@0 221
Daniel@0 222
Daniel@0 223 % Create HELP button
Daniel@0 224 uicontrol(fig, ...
Daniel@0 225 'Units', 'normalized', ...
Daniel@0 226 'Position' , [0.05 group2_bot+0.02 0.40 0.08], ...
Daniel@0 227 'String', 'Help', ...
Daniel@0 228 'Callback', 'demnlab help');
Daniel@0 229
Daniel@0 230 % Create CLOSE button
Daniel@0 231 uicontrol(fig, ...
Daniel@0 232 'Units', 'normalized', ...
Daniel@0 233 'Position' , [0.55 group2_bot+0.02 0.40 0.08], ...
Daniel@0 234 'String', 'Close', ...
Daniel@0 235 'Callback', 'close(gcf)');
Daniel@0 236
Daniel@0 237 hndlList=[fig hPop1 hPop2 hPop3 hPop4 hPop5 hPop6];
Daniel@0 238 set(fig, 'UserData', hndlList);
Daniel@0 239 set(fig, 'HandleVisibility', 'callback');
Daniel@0 240
Daniel@0 241 elseif strcmp(action, 'popup1'),
Daniel@0 242
Daniel@0 243 hndlList=get(gcf,'UserData');
Daniel@0 244 hPop = hndlList(2);
Daniel@0 245
Daniel@0 246 selected = get(hPop, 'Val');
Daniel@0 247 set(hPop, 'Val', [1]);
Daniel@0 248
Daniel@0 249 switch selected
Daniel@0 250 case 2
Daniel@0 251 demmlp1;
Daniel@0 252 case 3
Daniel@0 253 demrbf1;
Daniel@0 254 case 4
Daniel@0 255 demmdn1;
Daniel@0 256 end;
Daniel@0 257
Daniel@0 258 elseif strcmp(action,'popup2'),
Daniel@0 259
Daniel@0 260 hndlList=get(gcf,'UserData');
Daniel@0 261 hPop = hndlList(3);
Daniel@0 262
Daniel@0 263 selected = get(hPop, 'Val');
Daniel@0 264 set(hPop, 'Val', [1]);
Daniel@0 265
Daniel@0 266 switch selected
Daniel@0 267 case 2
Daniel@0 268 demglm1;
Daniel@0 269 case 3
Daniel@0 270 demglm2;
Daniel@0 271 case 4
Daniel@0 272 demmlp2;
Daniel@0 273 case 5
Daniel@0 274 demknn1;
Daniel@0 275 end
Daniel@0 276
Daniel@0 277 elseif strcmp(action,'popup3'),
Daniel@0 278
Daniel@0 279 hndlList=get(gcf,'UserData');
Daniel@0 280 hPop = hndlList(4);
Daniel@0 281
Daniel@0 282 selected = get(hPop, 'Val');
Daniel@0 283 set(hPop, 'Val', [1]);
Daniel@0 284
Daniel@0 285 switch selected
Daniel@0 286 case 2
Daniel@0 287 demgmm1;
Daniel@0 288 case 3
Daniel@0 289 demgmm2;
Daniel@0 290 case 4
Daniel@0 291 demgmm3;
Daniel@0 292 case 5
Daniel@0 293 demgmm4;
Daniel@0 294 case 6
Daniel@0 295 demns1;
Daniel@0 296 case 7
Daniel@0 297 demgtm1;
Daniel@0 298 case 8
Daniel@0 299 demgtm2;
Daniel@0 300 case 9
Daniel@0 301 demkmn1;
Daniel@0 302 case 10
Daniel@0 303 demsom1;
Daniel@0 304 end
Daniel@0 305
Daniel@0 306 elseif strcmp(action,'popup4'),
Daniel@0 307
Daniel@0 308 hndlList=get(gcf,'UserData');
Daniel@0 309 hPop = hndlList(5);
Daniel@0 310
Daniel@0 311 selected = get(hPop, 'Val');
Daniel@0 312 set(hPop, 'Val', [1]);
Daniel@0 313
Daniel@0 314 switch selected
Daniel@0 315 case 2
Daniel@0 316 demprior;
Daniel@0 317 case 3
Daniel@0 318 demev1;
Daniel@0 319 case 4
Daniel@0 320 demev3;
Daniel@0 321 case 5
Daniel@0 322 demev2;
Daniel@0 323 case 6
Daniel@0 324 demard;
Daniel@0 325 case 7
Daniel@0 326 demprgp;
Daniel@0 327 case 8
Daniel@0 328 demgp;
Daniel@0 329 case 9
Daniel@0 330 demgpard;
Daniel@0 331 end
Daniel@0 332
Daniel@0 333 elseif strcmp(action,'popup5'),
Daniel@0 334
Daniel@0 335 hndlList=get(gcf,'UserData');
Daniel@0 336 hPop = hndlList(6);
Daniel@0 337
Daniel@0 338 selected = get(hPop, 'Val');
Daniel@0 339 set(hPop, 'Val', [1]);
Daniel@0 340
Daniel@0 341 switch selected
Daniel@0 342 case 2
Daniel@0 343 demopt1;
Daniel@0 344 case 3
Daniel@0 345 demolgd1;
Daniel@0 346 case 4
Daniel@0 347 demhint;
Daniel@0 348 end
Daniel@0 349
Daniel@0 350
Daniel@0 351 elseif strcmp(action,'popup6'),
Daniel@0 352
Daniel@0 353 hndlList=get(gcf,'UserData');
Daniel@0 354 hPop = hndlList(7);
Daniel@0 355
Daniel@0 356 selected = get(hPop, 'Val');
Daniel@0 357 set(hPop, 'Val', [1]);
Daniel@0 358
Daniel@0 359 switch selected
Daniel@0 360 case 2
Daniel@0 361 demgauss;
Daniel@0 362 case 3
Daniel@0 363 demmet1;
Daniel@0 364 case 4
Daniel@0 365 demhmc1;
Daniel@0 366 case 5
Daniel@0 367 demhmc2;
Daniel@0 368 case 6
Daniel@0 369 demhmc3;
Daniel@0 370 end
Daniel@0 371
Daniel@0 372 elseif strcmp(action, 'help'),
Daniel@0 373
Daniel@0 374 helpStr = {'To run a demo, press the appropriate button.'; ...
Daniel@0 375 'Instructions and information will appear in the Matlab';...
Daniel@0 376 'command window.'};
Daniel@0 377
Daniel@0 378 hHelpDlg = helpdlg(helpStr, 'Netlab Demo Help');
Daniel@0 379
Daniel@0 380 end;