wolffd@0
|
1 function demhint(nin, nhidden, nout)
|
wolffd@0
|
2 %DEMHINT Demonstration of Hinton diagram for 2-layer feed-forward network.
|
wolffd@0
|
3 %
|
wolffd@0
|
4 % Description
|
wolffd@0
|
5 %
|
wolffd@0
|
6 % DEMHINT plots a Hinton diagram for a 2-layer feedforward network with
|
wolffd@0
|
7 % 5 inputs, 4 hidden units and 3 outputs. The weight vector is chosen
|
wolffd@0
|
8 % from a Gaussian distribution as described under MLP.
|
wolffd@0
|
9 %
|
wolffd@0
|
10 % DEMHINT(NIN, NHIDDEN, NOUT) allows the user to specify the number of
|
wolffd@0
|
11 % inputs, hidden units and outputs.
|
wolffd@0
|
12 %
|
wolffd@0
|
13 % See also
|
wolffd@0
|
14 % HINTON, HINTMAT, MLP, MLPPAK, MLPUNPAK
|
wolffd@0
|
15 %
|
wolffd@0
|
16
|
wolffd@0
|
17 % Copyright (c) Ian T Nabney (1996-2001)
|
wolffd@0
|
18
|
wolffd@0
|
19 if nargin < 1 nin = 5; end
|
wolffd@0
|
20 if nargin < 2 nhidden = 7; end
|
wolffd@0
|
21 if nargin < 3 nout = 3; end
|
wolffd@0
|
22
|
wolffd@0
|
23 % Fix the seed for reproducible results
|
wolffd@0
|
24 randn('state', 42);
|
wolffd@0
|
25 clc
|
wolffd@0
|
26 disp('This demonstration illustrates the plotting of Hinton diagrams')
|
wolffd@0
|
27 disp('for Multi-Layer Perceptron networks.')
|
wolffd@0
|
28 disp(' ')
|
wolffd@0
|
29 disp('Press any key to continue.')
|
wolffd@0
|
30 pause
|
wolffd@0
|
31 net = mlp(nin, nhidden, nout, 'linear');
|
wolffd@0
|
32
|
wolffd@0
|
33 [h1, h2] = mlphint(net);
|
wolffd@0
|
34 clc
|
wolffd@0
|
35 disp('The MLP has been created with')
|
wolffd@0
|
36 disp([' ' int2str(nin) ' inputs'])
|
wolffd@0
|
37 disp([' ' int2str(nhidden) ' hidden units'])
|
wolffd@0
|
38 disp([' ' int2str(nout) ' outputs'])
|
wolffd@0
|
39 disp(' ')
|
wolffd@0
|
40 disp('One figure is produced for each layer of weights.')
|
wolffd@0
|
41 disp('For each layer the fan-in weights are arranged in rows for each unit.')
|
wolffd@0
|
42 disp('The bias weight is separated from the rest by a red vertical line.')
|
wolffd@0
|
43 disp('The area of each box is proportional to the weight value: positive')
|
wolffd@0
|
44 disp('values are white, and negative are black.')
|
wolffd@0
|
45 disp(' ')
|
wolffd@0
|
46 disp('Press any key to exit.');
|
wolffd@0
|
47 pause;
|
wolffd@0
|
48 delete(h1);
|
wolffd@0
|
49 delete(h2);
|