comparison toolboxes/FullBNT-1.0.7/netlab3.3/hinton.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function h = hinton(w);
2 %HINTON Plot Hinton diagram for a weight matrix.
3 %
4 % Description
5 %
6 % HINTON(W) takes a matrix W and plots the Hinton diagram.
7 %
8 % H = HINTON(NET) also returns the figure handle H which can be used,
9 % for instance, to delete the figure when it is no longer needed.
10 %
11 % To print the figure correctly in black and white, you should call
12 % SET(H, 'INVERTHARDCOPY', 'OFF') before printing.
13 %
14 % See also
15 % DEMHINT, HINTMAT, MLPHINT
16 %
17
18 % Copyright (c) Ian T Nabney (1996-2001)
19
20 % Set scale to be up to 0.9 of maximum absolute weight value, where scale
21 % defined so that area of box proportional to weight value.
22
23 % Use no more than 640x480 pixels
24 xmax = 640; ymax = 480;
25
26 % Offset bottom left hand corner
27 x01 = 40; y01 = 40;
28 x02 = 80; y02 = 80;
29
30 % Need to allow 5 pixels border for window frame: but 30 at top
31 border = 5;
32 top_border = 30;
33
34 ymax = ymax - top_border;
35 xmax = xmax - border;
36
37 % First layer
38
39 [xvals, yvals, color] = hintmat(w);
40 % Try to preserve aspect ratio approximately
41 if (8*size(w, 1) < 6*size(w, 2))
42 delx = xmax; dely = xmax*size(w, 1)/(size(w, 2));
43 else
44 delx = ymax*size(w, 2)/size(w, 1); dely = ymax;
45 end
46
47 h = figure('Color', [0.5 0.5 0.5], ...
48 'Name', 'Hinton diagram', ...
49 'NumberTitle', 'off', ...
50 'Colormap', [0 0 0; 1 1 1], ...
51 'Units', 'pixels', ...
52 'Position', [x01 y01 delx dely]);
53 set(gca, 'Visible', 'off', 'Position', [0 0 1 1]);
54 hold on
55 patch(xvals', yvals', color', 'Edgecolor', 'none');
56 axis equal;
57