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