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