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