Daniel@0: function jac = rbfjacob(net, x) Daniel@0: %RBFJACOB Evaluate derivatives of RBF network outputs with respect to inputs. Daniel@0: % Daniel@0: % Description Daniel@0: % G = RBFJACOB(NET, X) takes a network data structure NET and a matrix Daniel@0: % of input vectors X and returns a three-index matrix G whose I, J, K Daniel@0: % element contains the derivative of network output K with respect to Daniel@0: % input parameter J for input pattern I. Daniel@0: % Daniel@0: % See also Daniel@0: % RBF, RBFGRAD, RBFBKP 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: if ~strcmp(net.outfn, 'linear') Daniel@0: error('Function only implemented for linear outputs') Daniel@0: end Daniel@0: Daniel@0: [y, z, n2] = rbffwd(net, x); Daniel@0: Daniel@0: ndata = size(x, 1); Daniel@0: jac = zeros(ndata, net.nin, net.nout); Daniel@0: Psi = zeros(net.nin, net.nhidden); Daniel@0: % Calculate derivative of activations wrt n2 Daniel@0: switch net.actfn Daniel@0: case 'gaussian' Daniel@0: dz = -z./(ones(ndata, 1)*net.wi); Daniel@0: case 'tps' Daniel@0: dz = 2*(1 + log(n2+(n2==0))); Daniel@0: case 'r4logr' Daniel@0: dz = 2*(n2.*(1+2.*log(n2+(n2==0)))); Daniel@0: otherwise Daniel@0: error(['Unknown activation function ', net.actfn]); Daniel@0: end Daniel@0: Daniel@0: % Ignore biases as they cannot affect Jacobian Daniel@0: for n = 1:ndata Daniel@0: Psi = (ones(net.nin, 1)*dz(n, :)).* ... Daniel@0: (x(n, :)'*ones(1, net.nhidden) - net.c'); Daniel@0: % Now compute the Jacobian Daniel@0: jac(n, :, :) = Psi * net.w2; Daniel@0: end