| Neural Network Toolbox | |
| Provide feedback about this page |
Euclidean distance weight function
Syntax
Z = dist(W,P,FP) info = dist(code) dim = dist('size',S,R,FP) dp = dist('dp',W,P,Z,FP) dw = dist('dw',W,P,Z,FP) D = dist(pos)
Description
dist is the Euclidean distance weight function. Weight functions apply weights to an input to get weighted inputs.
dist(W,P,FP) takes these inputs,
W |
S x R weight matrix |
P |
R x Q matrix of Q input (column) vectors |
FP |
Struct of function parameters (optional, ignored) |
and returns the S x Q matrix of vector distances.
dist(code) returns information about this function. The following codes are defined:
dist('size',S,R,FP) takes the layer dimension S, input dimension R, and function parameters, and returns the weight size [S x R].
dist('dp',W,P,Z,FP) returns the derivative of Z with respect to P.
dist('dw',W,P,Z,FP) returns the derivative of Z with respect to W.
dist is also a layer distance function which can be used to find the distances between neurons in a layer.
pos |
N x S matrix of neuron positions |
and returns the S x S matrix of distances.
Examples
Here you define a random weight matrix W and input vector P and calculate the corresponding weighted input Z.
Here you define a random matrix of positions for 10 neurons arranged in three-dimensional space and find their distances.
Network Use
You can create a standard network that uses dist by calling newpnn or newgrnn.
To change a network so an input weight uses dist, set net.inputWeight{i,j}.weightFcn to 'dist'. For a layer weight, set net.layerWeight{i,j}.weightFcn to 'dist'.
To change a network so that a layer's topology uses dist, set net.layers{i}.distanceFcn to 'dist'.
In either case, call sim to simulate the network with dist.
See newpnn or newgrnn for simulation examples.
Algorithm
The Euclidean distance d between two vectors X and Y is
See Also
sim, dotprod, negdist, normprod, mandist, linkdist
| Provide feedback about this page |
![]() | display | divideblock | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |