wolffd@0: function [d2, win_nodes] = somfwd(net, x) wolffd@0: %SOMFWD Forward propagation through a Self-Organising Map. wolffd@0: % wolffd@0: % Description wolffd@0: % D2 = SOMFWD(NET, X) propagates the data matrix X through a SOM NET, wolffd@0: % returning the squared distance matrix D2 with dimension NIN by wolffd@0: % NUM_NODES. The $i$th row represents the squared Euclidean distance wolffd@0: % to each of the nodes of the SOM. wolffd@0: % wolffd@0: % [D2, WIN_NODES] = SOMFWD(NET, X) also returns the indices of the wolffd@0: % winning nodes for each pattern. wolffd@0: % wolffd@0: % See also wolffd@0: % SOM, SOMTRAIN wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check for consistency wolffd@0: errstring = consist(net, 'som', x); wolffd@0: if ~isempty(errstring) wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: % Turn nodes into matrix of centres wolffd@0: nodes = (reshape(net.map, net.nin, net.num_nodes))'; wolffd@0: % Compute squared distance matrix wolffd@0: d2 = dist2(x, nodes); wolffd@0: % Find winning node for each pattern: minimum value in each row wolffd@0: [w, win_nodes] = min(d2, [], 2);