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

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