comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [d2, win_nodes] = somfwd(net, x)
2 %SOMFWD Forward propagation through a Self-Organising Map.
3 %
4 % Description
5 % D2 = SOMFWD(NET, X) propagates the data matrix X through a SOM NET,
6 % returning the squared distance matrix D2 with dimension NIN by
7 % NUM_NODES. The $i$th row represents the squared Euclidean distance
8 % to each of the nodes of the SOM.
9 %
10 % [D2, WIN_NODES] = SOMFWD(NET, X) also returns the indices of the
11 % winning nodes for each pattern.
12 %
13 % See also
14 % SOM, SOMTRAIN
15 %
16
17 % Copyright (c) Ian T Nabney (1996-2001)
18
19 % Check for consistency
20 errstring = consist(net, 'som', x);
21 if ~isempty(errstring)
22 error(errstring);
23 end
24
25 % Turn nodes into matrix of centres
26 nodes = (reshape(net.map, net.nin, net.num_nodes))';
27 % Compute squared distance matrix
28 d2 = dist2(x, nodes);
29 % Find winning node for each pattern: minimum value in each row
30 [w, win_nodes] = min(d2, [], 2);