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