wolffd@0: function demhint(nin, nhidden, nout) wolffd@0: %DEMHINT Demonstration of Hinton diagram for 2-layer feed-forward network. wolffd@0: % wolffd@0: % Description wolffd@0: % wolffd@0: % DEMHINT plots a Hinton diagram for a 2-layer feedforward network with wolffd@0: % 5 inputs, 4 hidden units and 3 outputs. The weight vector is chosen wolffd@0: % from a Gaussian distribution as described under MLP. wolffd@0: % wolffd@0: % DEMHINT(NIN, NHIDDEN, NOUT) allows the user to specify the number of wolffd@0: % inputs, hidden units and outputs. wolffd@0: % wolffd@0: % See also wolffd@0: % HINTON, HINTMAT, MLP, MLPPAK, MLPUNPAK wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: if nargin < 1 nin = 5; end wolffd@0: if nargin < 2 nhidden = 7; end wolffd@0: if nargin < 3 nout = 3; end wolffd@0: wolffd@0: % Fix the seed for reproducible results wolffd@0: randn('state', 42); wolffd@0: clc wolffd@0: disp('This demonstration illustrates the plotting of Hinton diagrams') wolffd@0: disp('for Multi-Layer Perceptron networks.') wolffd@0: disp(' ') wolffd@0: disp('Press any key to continue.') wolffd@0: pause wolffd@0: net = mlp(nin, nhidden, nout, 'linear'); wolffd@0: wolffd@0: [h1, h2] = mlphint(net); wolffd@0: clc wolffd@0: disp('The MLP has been created with') wolffd@0: disp([' ' int2str(nin) ' inputs']) wolffd@0: disp([' ' int2str(nhidden) ' hidden units']) wolffd@0: disp([' ' int2str(nout) ' outputs']) wolffd@0: disp(' ') wolffd@0: disp('One figure is produced for each layer of weights.') wolffd@0: disp('For each layer the fan-in weights are arranged in rows for each unit.') wolffd@0: disp('The bias weight is separated from the rest by a red vertical line.') wolffd@0: disp('The area of each box is proportional to the weight value: positive') wolffd@0: disp('values are white, and negative are black.') wolffd@0: disp(' ') wolffd@0: disp('Press any key to exit.'); wolffd@0: pause; wolffd@0: delete(h1); wolffd@0: delete(h2);