matlab - Get hextop self-organizing map neuron connections -
how n-by-2 vector contains connections of neurons in som? example, if have simple 2x2 hextop som, connections vector should like:
[ 1 2 1 3 1 4 ]
this vector indicates neuron 1 connected neuron 2, neuron 1 connected neuron 3, etc.
how can connections vector retrieved given som?
assuming som defined neighbourhood distance 1 (i.e., each neuron, edges neurons within euclidian distance of 1), default option matlabs hextop(...)
command, can create connections vector follows:
pos = hextop(2,2); % find neurons within euclidean distance of 1, each neuron. % option a: count edges once distmat = triu(dist(pos)); [i, j] = find(distmat > 0 & distmat <= 1); connectionsvectora = [i j] % option b: count edges in both directions distmat = dist(pos); [i, j] = find(distmat > 0 & distmat <= 1); connectionsvectorb = sortrows([i j]) % verify graphically plotsom(pos)
the output above follows:
connectionsvectora = 1 2 1 3 2 3 2 4 3 4 connectionsvectorb = 1 2 1 3 2 1 2 3 2 4 3 1 3 2 3 4 4 2 4 3
if have som non-default neighbourhood distance (!= 1
), ndist
, replace find(..)
commands above with
... find(distmat > 0 & distmat <= ndist);
Comments
Post a Comment