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