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