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