comparison toolboxes/FullBNT-1.0.7/netlab3.3/rbferr.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 [e, edata, eprior] = rbferr(net, x, t)
2 %RBFERR Evaluate error function for RBF network.
3 %
4 % Description
5 % E = RBFERR(NET, X, T) takes a network data structure NET together
6 % with a matrix X of input vectors and a matrix T of target vectors,
7 % and evaluates the appropriate error function E depending on
8 % NET.OUTFN. Each row of X corresponds to one input vector and each
9 % row of T contains the corresponding target vector.
10 %
11 % [E, EDATA, EPRIOR] = RBFERR(NET, X, T) additionally returns the data
12 % and prior components of the error, assuming a zero mean Gaussian
13 % prior on the weights with inverse variance parameters ALPHA and BETA
14 % taken from the network data structure NET.
15 %
16 % See also
17 % RBF, RBFFWD, RBFGRAD, RBFPAK, RBFTRAIN, RBFUNPAK
18 %
19
20 % Copyright (c) Ian T Nabney (1996-2001)
21
22 % Check arguments for consistency
23 switch net.outfn
24 case 'linear'
25 errstring = consist(net, 'rbf', x, t);
26 case 'neuroscale'
27 errstring = consist(net, 'rbf', x);
28 otherwise
29 error(['Unknown output function ', net.outfn]);
30 end
31 if ~isempty(errstring);
32 error(errstring);
33 end
34
35 switch net.outfn
36 case 'linear'
37 y = rbffwd(net, x);
38 edata = 0.5*sum(sum((y - t).^2));
39 case 'neuroscale'
40 y = rbffwd(net, x);
41 y_dist = sqrt(dist2(y, y));
42 % Take t as target distance matrix
43 edata = 0.5.*(sum(sum((t-y_dist).^2)));
44 otherwise
45 error(['Unknown output function ', net.outfn]);
46 end
47
48 % Compute Bayesian regularised error
49 [e, edata, eprior] = errbayes(net, edata);
50