Mercurial > hg > camir-ismir2012
annotate toolboxes/FullBNT-1.0.7/netlab3.3/mlpbkp.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 = mlpbkp(net, x, z, deltas) |
Daniel@0 | 2 %MLPBKP Backpropagate gradient of error function for 2-layer network. |
Daniel@0 | 3 % |
Daniel@0 | 4 % Description |
Daniel@0 | 5 % G = MLPBKP(NET, X, Z, DELTAS) takes a network data structure NET |
Daniel@0 | 6 % together with a matrix X of input vectors, a matrix Z of hidden unit |
Daniel@0 | 7 % activations, and a matrix DELTAS of the gradient of the error |
Daniel@0 | 8 % function with respect to the values of the output units (i.e. the |
Daniel@0 | 9 % summed inputs to the output units, before the activation function is |
Daniel@0 | 10 % applied). The return value is the gradient G of the error function |
Daniel@0 | 11 % with respect to the network weights. Each row of X corresponds to one |
Daniel@0 | 12 % input vector. |
Daniel@0 | 13 % |
Daniel@0 | 14 % This function is provided so that the common backpropagation |
Daniel@0 | 15 % algorithm can be used by multi-layer perceptron network models to |
Daniel@0 | 16 % compute gradients for mixture density networks as well as standard |
Daniel@0 | 17 % error functions. |
Daniel@0 | 18 % |
Daniel@0 | 19 % See also |
Daniel@0 | 20 % MLP, MLPGRAD, MLPDERIV, MDNGRAD |
Daniel@0 | 21 % |
Daniel@0 | 22 |
Daniel@0 | 23 % Copyright (c) Ian T Nabney (1996-2001) |
Daniel@0 | 24 |
Daniel@0 | 25 % Evaluate second-layer gradients. |
Daniel@0 | 26 gw2 = z'*deltas; |
Daniel@0 | 27 gb2 = sum(deltas, 1); |
Daniel@0 | 28 |
Daniel@0 | 29 % Now do the backpropagation. |
Daniel@0 | 30 delhid = deltas*net.w2'; |
Daniel@0 | 31 delhid = delhid.*(1.0 - z.*z); |
Daniel@0 | 32 |
Daniel@0 | 33 % Finally, evaluate the first-layer gradients. |
Daniel@0 | 34 gw1 = x'*delhid; |
Daniel@0 | 35 gb1 = sum(delhid, 1); |
Daniel@0 | 36 |
Daniel@0 | 37 g = [gw1(:)', gb1, gw2(:)', gb2]; |