Mercurial > hg > camir-aes2014
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [g, gdata, gprior] = glmgrad(net, x, t) | |
2 %GLMGRAD Evaluate gradient of error function for generalized linear model. | |
3 % | |
4 % Description | |
5 % G = GLMGRAD(NET, X, T) takes a generalized linear model data | |
6 % structure NET together with a matrix X of input vectors and a matrix | |
7 % T of target vectors, and evaluates the gradient G of the error | |
8 % function with respect to the network weights. The error function | |
9 % corresponds to the choice of output unit activation function. Each | |
10 % row of X corresponds to one input vector and each row of T | |
11 % corresponds to one target vector. | |
12 % | |
13 % [G, GDATA, GPRIOR] = GLMGRAD(NET, X, T) also returns separately the | |
14 % data and prior contributions to the gradient. | |
15 % | |
16 % See also | |
17 % GLM, GLMPAK, GLMUNPAK, GLMFWD, GLMERR, GLMTRAIN | |
18 % | |
19 | |
20 % Copyright (c) Ian T Nabney (1996-2001) | |
21 | |
22 % Check arguments for consistency | |
23 errstring = consist(net, 'glm', x, t); | |
24 if ~isempty(errstring); | |
25 error(errstring); | |
26 end | |
27 | |
28 y = glmfwd(net, x); | |
29 delout = y - t; | |
30 | |
31 gw1 = x'*delout; | |
32 gb1 = sum(delout, 1); | |
33 | |
34 gdata = [gw1(:)', gb1]; | |
35 | |
36 [g, gdata, gprior] = gbayes(net, gdata); |