Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/netlab3.3/glmgrad.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function [g, gdata, gprior] = glmgrad(net, x, t) |
wolffd@0 | 2 %GLMGRAD Evaluate gradient of error function for generalized linear model. |
wolffd@0 | 3 % |
wolffd@0 | 4 % Description |
wolffd@0 | 5 % G = GLMGRAD(NET, X, T) takes a generalized linear model data |
wolffd@0 | 6 % structure NET together with a matrix X of input vectors and a matrix |
wolffd@0 | 7 % T of target vectors, and evaluates the gradient G of the error |
wolffd@0 | 8 % function with respect to the network weights. The error function |
wolffd@0 | 9 % corresponds to the choice of output unit activation function. Each |
wolffd@0 | 10 % row of X corresponds to one input vector and each row of T |
wolffd@0 | 11 % corresponds to one target vector. |
wolffd@0 | 12 % |
wolffd@0 | 13 % [G, GDATA, GPRIOR] = GLMGRAD(NET, X, T) also returns separately the |
wolffd@0 | 14 % data and prior contributions to the gradient. |
wolffd@0 | 15 % |
wolffd@0 | 16 % See also |
wolffd@0 | 17 % GLM, GLMPAK, GLMUNPAK, GLMFWD, GLMERR, GLMTRAIN |
wolffd@0 | 18 % |
wolffd@0 | 19 |
wolffd@0 | 20 % Copyright (c) Ian T Nabney (1996-2001) |
wolffd@0 | 21 |
wolffd@0 | 22 % Check arguments for consistency |
wolffd@0 | 23 errstring = consist(net, 'glm', x, t); |
wolffd@0 | 24 if ~isempty(errstring); |
wolffd@0 | 25 error(errstring); |
wolffd@0 | 26 end |
wolffd@0 | 27 |
wolffd@0 | 28 y = glmfwd(net, x); |
wolffd@0 | 29 delout = y - t; |
wolffd@0 | 30 |
wolffd@0 | 31 gw1 = x'*delout; |
wolffd@0 | 32 gb1 = sum(delout, 1); |
wolffd@0 | 33 |
wolffd@0 | 34 gdata = [gw1(:)', gb1]; |
wolffd@0 | 35 |
wolffd@0 | 36 [g, gdata, gprior] = gbayes(net, gdata); |