wolffd@0: function [a, z, n2] = rbffwd(net, x) wolffd@0: %RBFFWD Forward propagation through RBF network with linear outputs. wolffd@0: % wolffd@0: % Description wolffd@0: % A = RBFFWD(NET, X) takes a network data structure NET and a matrix X wolffd@0: % of input vectors and forward propagates the inputs through the wolffd@0: % network to generate a matrix A of output vectors. Each row of X wolffd@0: % corresponds to one input vector and each row of A contains the wolffd@0: % corresponding output vector. The activation function that is used is wolffd@0: % determined by NET.ACTFN. wolffd@0: % wolffd@0: % [A, Z, N2] = RBFFWD(NET, X) also generates a matrix Z of the hidden wolffd@0: % unit activations where each row corresponds to one pattern. These wolffd@0: % hidden unit activations represent the design matrix for the RBF. The wolffd@0: % matrix N2 is the squared distances between each basis function centre wolffd@0: % and each pattern in which each row corresponds to a data point. wolffd@0: % wolffd@0: % See also wolffd@0: % RBF, RBFERR, RBFGRAD, RBFPAK, RBFTRAIN, RBFUNPAK wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: errstring = consist(net, 'rbf', x); wolffd@0: if ~isempty(errstring); wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: [ndata, data_dim] = size(x); wolffd@0: wolffd@0: % Calculate squared norm matrix, of dimension (ndata, ncentres) wolffd@0: n2 = dist2(x, net.c); wolffd@0: wolffd@0: % Switch on activation function type wolffd@0: switch net.actfn wolffd@0: wolffd@0: case 'gaussian' % Gaussian wolffd@0: % Calculate width factors: net.wi contains squared widths wolffd@0: wi2 = ones(ndata, 1) * (2 .* net.wi); wolffd@0: wolffd@0: % Now compute the activations wolffd@0: z = exp(-(n2./wi2)); wolffd@0: wolffd@0: case 'tps' % Thin plate spline wolffd@0: z = n2.*log(n2+(n2==0)); wolffd@0: wolffd@0: case 'r4logr' % r^4 log r wolffd@0: z = n2.*n2.*log(n2+(n2==0)); wolffd@0: wolffd@0: otherwise wolffd@0: error('Unknown activation function in rbffwd') wolffd@0: end wolffd@0: wolffd@0: a = z*net.w2 + ones(ndata, 1)*net.b2;