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