annotate toolboxes/FullBNT-1.0.7/netlab3.3/rbfjacob.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function jac = rbfjacob(net, x)
wolffd@0 2 %RBFJACOB Evaluate derivatives of RBF network outputs with respect to inputs.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % G = RBFJACOB(NET, X) takes a network data structure NET and a matrix
wolffd@0 6 % of input vectors X and returns a three-index matrix G whose I, J, K
wolffd@0 7 % element contains the derivative of network output K with respect to
wolffd@0 8 % input parameter J for input pattern I.
wolffd@0 9 %
wolffd@0 10 % See also
wolffd@0 11 % RBF, RBFGRAD, RBFBKP
wolffd@0 12 %
wolffd@0 13
wolffd@0 14 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 15
wolffd@0 16 % Check arguments for consistency
wolffd@0 17 errstring = consist(net, 'rbf', x);
wolffd@0 18 if ~isempty(errstring);
wolffd@0 19 error(errstring);
wolffd@0 20 end
wolffd@0 21
wolffd@0 22 if ~strcmp(net.outfn, 'linear')
wolffd@0 23 error('Function only implemented for linear outputs')
wolffd@0 24 end
wolffd@0 25
wolffd@0 26 [y, z, n2] = rbffwd(net, x);
wolffd@0 27
wolffd@0 28 ndata = size(x, 1);
wolffd@0 29 jac = zeros(ndata, net.nin, net.nout);
wolffd@0 30 Psi = zeros(net.nin, net.nhidden);
wolffd@0 31 % Calculate derivative of activations wrt n2
wolffd@0 32 switch net.actfn
wolffd@0 33 case 'gaussian'
wolffd@0 34 dz = -z./(ones(ndata, 1)*net.wi);
wolffd@0 35 case 'tps'
wolffd@0 36 dz = 2*(1 + log(n2+(n2==0)));
wolffd@0 37 case 'r4logr'
wolffd@0 38 dz = 2*(n2.*(1+2.*log(n2+(n2==0))));
wolffd@0 39 otherwise
wolffd@0 40 error(['Unknown activation function ', net.actfn]);
wolffd@0 41 end
wolffd@0 42
wolffd@0 43 % Ignore biases as they cannot affect Jacobian
wolffd@0 44 for n = 1:ndata
wolffd@0 45 Psi = (ones(net.nin, 1)*dz(n, :)).* ...
wolffd@0 46 (x(n, :)'*ones(1, net.nhidden) - net.c');
wolffd@0 47 % Now compute the Jacobian
wolffd@0 48 jac(n, :, :) = Psi * net.w2;
wolffd@0 49 end