annotate toolboxes/FullBNT-1.0.7/netlab3.3/rbfderiv.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 g = rbfderiv(net, x)
wolffd@0 2 %RBFDERIV Evaluate derivatives of RBF network outputs with respect to weights.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % G = RBFDERIV(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 % weight or bias parameter J for input pattern I. The ordering of the
wolffd@0 9 % weight and bias parameters is defined by RBFUNPAK. This function
wolffd@0 10 % also takes into account any mask in the network data structure.
wolffd@0 11 %
wolffd@0 12 % See also
wolffd@0 13 % RBF, RBFPAK, RBFGRAD, RBFBKP
wolffd@0 14 %
wolffd@0 15
wolffd@0 16 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 17
wolffd@0 18 % Check arguments for consistency
wolffd@0 19 errstring = consist(net, 'rbf', x);
wolffd@0 20 if ~isempty(errstring);
wolffd@0 21 error(errstring);
wolffd@0 22 end
wolffd@0 23
wolffd@0 24 if ~strcmp(net.outfn, 'linear')
wolffd@0 25 error('Function only implemented for linear outputs')
wolffd@0 26 end
wolffd@0 27
wolffd@0 28 [y, z, n2] = rbffwd(net, x);
wolffd@0 29 ndata = size(x, 1);
wolffd@0 30
wolffd@0 31 if isfield(net, 'mask')
wolffd@0 32 nwts = size(find(net.mask), 1);
wolffd@0 33 temp = zeros(1, net.nwts);
wolffd@0 34 else
wolffd@0 35 nwts = net.nwts;
wolffd@0 36 end
wolffd@0 37
wolffd@0 38 g = zeros(ndata, nwts, net.nout);
wolffd@0 39 for k = 1 : net.nout
wolffd@0 40 delta = zeros(1, net.nout);
wolffd@0 41 delta(1, k) = 1;
wolffd@0 42 for n = 1 : ndata
wolffd@0 43 if isfield(net, 'mask')
wolffd@0 44 temp = rbfbkp(net, x(n, :), z(n, :), n2(n, :), delta);
wolffd@0 45 g(n, :, k) = temp(logical(net.mask));
wolffd@0 46 else
wolffd@0 47 g(n, :, k) = rbfbkp(net, x(n, :), z(n, :), n2(n, :),...
wolffd@0 48 delta);
wolffd@0 49 end
wolffd@0 50 end
wolffd@0 51 end
wolffd@0 52
wolffd@0 53