annotate toolboxes/FullBNT-1.0.7/netlab3.3/somfwd.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [d2, win_nodes] = somfwd(net, x)
wolffd@0 2 %SOMFWD Forward propagation through a Self-Organising Map.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % D2 = SOMFWD(NET, X) propagates the data matrix X through a SOM NET,
wolffd@0 6 % returning the squared distance matrix D2 with dimension NIN by
wolffd@0 7 % NUM_NODES. The $i$th row represents the squared Euclidean distance
wolffd@0 8 % to each of the nodes of the SOM.
wolffd@0 9 %
wolffd@0 10 % [D2, WIN_NODES] = SOMFWD(NET, X) also returns the indices of the
wolffd@0 11 % winning nodes for each pattern.
wolffd@0 12 %
wolffd@0 13 % See also
wolffd@0 14 % SOM, SOMTRAIN
wolffd@0 15 %
wolffd@0 16
wolffd@0 17 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 18
wolffd@0 19 % Check for consistency
wolffd@0 20 errstring = consist(net, 'som', x);
wolffd@0 21 if ~isempty(errstring)
wolffd@0 22 error(errstring);
wolffd@0 23 end
wolffd@0 24
wolffd@0 25 % Turn nodes into matrix of centres
wolffd@0 26 nodes = (reshape(net.map, net.nin, net.num_nodes))';
wolffd@0 27 % Compute squared distance matrix
wolffd@0 28 d2 = dist2(x, nodes);
wolffd@0 29 % Find winning node for each pattern: minimum value in each row
wolffd@0 30 [w, win_nodes] = min(d2, [], 2);