Daniel@0: function g = rbfderiv(net, x) Daniel@0: %RBFDERIV Evaluate derivatives of RBF network outputs with respect to weights. Daniel@0: % Daniel@0: % Description Daniel@0: % G = RBFDERIV(NET, X) takes a network data structure NET and a matrix Daniel@0: % of input vectors X and returns a three-index matrix G whose I, J, K Daniel@0: % element contains the derivative of network output K with respect to Daniel@0: % weight or bias parameter J for input pattern I. The ordering of the Daniel@0: % weight and bias parameters is defined by RBFUNPAK. This function Daniel@0: % also takes into account any mask in the network data structure. Daniel@0: % Daniel@0: % See also Daniel@0: % RBF, RBFPAK, RBFGRAD, RBFBKP Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: % Check arguments for consistency Daniel@0: errstring = consist(net, 'rbf', x); Daniel@0: if ~isempty(errstring); Daniel@0: error(errstring); Daniel@0: end Daniel@0: Daniel@0: if ~strcmp(net.outfn, 'linear') Daniel@0: error('Function only implemented for linear outputs') Daniel@0: end Daniel@0: Daniel@0: [y, z, n2] = rbffwd(net, x); Daniel@0: ndata = size(x, 1); Daniel@0: Daniel@0: if isfield(net, 'mask') Daniel@0: nwts = size(find(net.mask), 1); Daniel@0: temp = zeros(1, net.nwts); Daniel@0: else Daniel@0: nwts = net.nwts; Daniel@0: end Daniel@0: Daniel@0: g = zeros(ndata, nwts, net.nout); Daniel@0: for k = 1 : net.nout Daniel@0: delta = zeros(1, net.nout); Daniel@0: delta(1, k) = 1; Daniel@0: for n = 1 : ndata Daniel@0: if isfield(net, 'mask') Daniel@0: temp = rbfbkp(net, x(n, :), z(n, :), n2(n, :), delta); Daniel@0: g(n, :, k) = temp(logical(net.mask)); Daniel@0: else Daniel@0: g(n, :, k) = rbfbkp(net, x(n, :), z(n, :), n2(n, :),... Daniel@0: delta); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: