wolffd@0: function [g, gdata, gprior] = mlpgrad(net, x, t) wolffd@0: %MLPGRAD Evaluate gradient of error function for 2-layer network. wolffd@0: % wolffd@0: % Description wolffd@0: % G = MLPGRAD(NET, X, T) takes a network data structure NET together wolffd@0: % with a matrix X of input vectors and a matrix T of target vectors, wolffd@0: % and evaluates the gradient G of the error function with respect to wolffd@0: % the network weights. The error funcion corresponds to the choice of wolffd@0: % output unit activation function. Each row of X corresponds to one wolffd@0: % input vector and each row of T corresponds to one target vector. wolffd@0: % wolffd@0: % [G, GDATA, GPRIOR] = MLPGRAD(NET, X, T) also returns separately the wolffd@0: % data and prior contributions to the gradient. In the case of multiple wolffd@0: % groups in the prior, GPRIOR is a matrix with a row for each group and wolffd@0: % a column for each weight parameter. wolffd@0: % wolffd@0: % See also wolffd@0: % MLP, MLPPAK, MLPUNPAK, MLPFWD, MLPERR, MLPBKP wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: errstring = consist(net, 'mlp', x, t); wolffd@0: if ~isempty(errstring); wolffd@0: error(errstring); wolffd@0: end wolffd@0: [y, z] = mlpfwd(net, x); wolffd@0: delout = y - t; wolffd@0: wolffd@0: gdata = mlpbkp(net, x, z, delout); wolffd@0: wolffd@0: [g, gdata, gprior] = gbayes(net, gdata);