annotate toolboxes/FullBNT-1.0.7/netlab3.3/mlpgrad.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, gdata, gprior] = mlpgrad(net, x, t)
Daniel@0 2 %MLPGRAD Evaluate gradient of error function for 2-layer network.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % G = MLPGRAD(NET, X, T) takes a network data structure NET together
Daniel@0 6 % with a matrix X of input vectors and a matrix T of target vectors,
Daniel@0 7 % and evaluates the gradient G of the error function with respect to
Daniel@0 8 % the network weights. The error funcion corresponds to the choice of
Daniel@0 9 % output unit activation function. Each row of X corresponds to one
Daniel@0 10 % input vector and each row of T corresponds to one target vector.
Daniel@0 11 %
Daniel@0 12 % [G, GDATA, GPRIOR] = MLPGRAD(NET, X, T) also returns separately the
Daniel@0 13 % data and prior contributions to the gradient. In the case of multiple
Daniel@0 14 % groups in the prior, GPRIOR is a matrix with a row for each group and
Daniel@0 15 % a column for each weight parameter.
Daniel@0 16 %
Daniel@0 17 % See also
Daniel@0 18 % MLP, MLPPAK, MLPUNPAK, MLPFWD, MLPERR, MLPBKP
Daniel@0 19 %
Daniel@0 20
Daniel@0 21 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 22
Daniel@0 23 % Check arguments for consistency
Daniel@0 24 errstring = consist(net, 'mlp', x, t);
Daniel@0 25 if ~isempty(errstring);
Daniel@0 26 error(errstring);
Daniel@0 27 end
Daniel@0 28 [y, z] = mlpfwd(net, x);
Daniel@0 29 delout = y - t;
Daniel@0 30
Daniel@0 31 gdata = mlpbkp(net, x, z, delout);
Daniel@0 32
Daniel@0 33 [g, gdata, gprior] = gbayes(net, gdata);