annotate toolboxes/FullBNT-1.0.7/netlab3.3/mlpderiv.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 = mlpderiv(net, x)
Daniel@0 2 %MLPDERIV Evaluate derivatives of network outputs with respect to weights.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % G = MLPDERIV(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 MLPUNPAK.
Daniel@0 10 %
Daniel@0 11 % See also
Daniel@0 12 % MLP, MLPPAK, MLPGRAD, MLPBKP
Daniel@0 13 %
Daniel@0 14
Daniel@0 15 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 16
Daniel@0 17 % Check arguments for consistency
Daniel@0 18 errstring = consist(net, 'mlp', x);
Daniel@0 19 if ~isempty(errstring);
Daniel@0 20 error(errstring);
Daniel@0 21 end
Daniel@0 22
Daniel@0 23 [y, z] = mlpfwd(net, x);
Daniel@0 24
Daniel@0 25 ndata = size(x, 1);
Daniel@0 26
Daniel@0 27 if isfield(net, 'mask')
Daniel@0 28 nwts = size(find(net.mask), 1);
Daniel@0 29 temp = zeros(1, net.nwts);
Daniel@0 30 else
Daniel@0 31 nwts = net.nwts;
Daniel@0 32 end
Daniel@0 33
Daniel@0 34 g = zeros(ndata, nwts, net.nout);
Daniel@0 35 for k = 1 : net.nout
Daniel@0 36 delta = zeros(1, net.nout);
Daniel@0 37 delta(1, k) = 1;
Daniel@0 38 for n = 1 : ndata
Daniel@0 39 if isfield(net, 'mask')
Daniel@0 40 temp = mlpbkp(net, x(n, :), z(n, :), delta);
Daniel@0 41 g(n, :, k) = temp(logical(net.mask));
Daniel@0 42 else
Daniel@0 43 g(n, :, k) = mlpbkp(net, x(n, :), z(n, :),...
Daniel@0 44 delta);
Daniel@0 45 end
Daniel@0 46 end
Daniel@0 47 end