Mercurial > hg > camir-aes2014
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/FullBNT-1.0.7/netlab3.3/rbferr.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,50 @@ +function [e, edata, eprior] = rbferr(net, x, t) +%RBFERR Evaluate error function for RBF network. +% +% Description +% E = RBFERR(NET, X, T) takes a network data structure NET together +% with a matrix X of input vectors and a matrix T of target vectors, +% and evaluates the appropriate error function E depending on +% NET.OUTFN. Each row of X corresponds to one input vector and each +% row of T contains the corresponding target vector. +% +% [E, EDATA, EPRIOR] = RBFERR(NET, X, T) additionally returns the data +% and prior components of the error, assuming a zero mean Gaussian +% prior on the weights with inverse variance parameters ALPHA and BETA +% taken from the network data structure NET. +% +% See also +% RBF, RBFFWD, RBFGRAD, RBFPAK, RBFTRAIN, RBFUNPAK +% + +% Copyright (c) Ian T Nabney (1996-2001) + +% Check arguments for consistency +switch net.outfn +case 'linear' + errstring = consist(net, 'rbf', x, t); +case 'neuroscale' + errstring = consist(net, 'rbf', x); +otherwise + error(['Unknown output function ', net.outfn]); +end +if ~isempty(errstring); + error(errstring); +end + +switch net.outfn +case 'linear' + y = rbffwd(net, x); + edata = 0.5*sum(sum((y - t).^2)); +case 'neuroscale' + y = rbffwd(net, x); + y_dist = sqrt(dist2(y, y)); + % Take t as target distance matrix + edata = 0.5.*(sum(sum((t-y_dist).^2))); +otherwise + error(['Unknown output function ', net.outfn]); +end + +% Compute Bayesian regularised error +[e, edata, eprior] = errbayes(net, edata); +