annotate toolboxes/FullBNT-1.0.7/netlab3.3/rbferr.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [e, edata, eprior] = rbferr(net, x, t)
Daniel@0 2 %RBFERR Evaluate error function for RBF network.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % E = RBFERR(NET, X, T) takes a network data structure NET together
Daniel@0 6 % with a matrix X of input vectors and a matrix T of target vectors,
Daniel@0 7 % and evaluates the appropriate error function E depending on
Daniel@0 8 % NET.OUTFN. Each row of X corresponds to one input vector and each
Daniel@0 9 % row of T contains the corresponding target vector.
Daniel@0 10 %
Daniel@0 11 % [E, EDATA, EPRIOR] = RBFERR(NET, X, T) additionally returns the data
Daniel@0 12 % and prior components of the error, assuming a zero mean Gaussian
Daniel@0 13 % prior on the weights with inverse variance parameters ALPHA and BETA
Daniel@0 14 % taken from the network data structure NET.
Daniel@0 15 %
Daniel@0 16 % See also
Daniel@0 17 % RBF, RBFFWD, RBFGRAD, RBFPAK, RBFTRAIN, RBFUNPAK
Daniel@0 18 %
Daniel@0 19
Daniel@0 20 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 21
Daniel@0 22 % Check arguments for consistency
Daniel@0 23 switch net.outfn
Daniel@0 24 case 'linear'
Daniel@0 25 errstring = consist(net, 'rbf', x, t);
Daniel@0 26 case 'neuroscale'
Daniel@0 27 errstring = consist(net, 'rbf', x);
Daniel@0 28 otherwise
Daniel@0 29 error(['Unknown output function ', net.outfn]);
Daniel@0 30 end
Daniel@0 31 if ~isempty(errstring);
Daniel@0 32 error(errstring);
Daniel@0 33 end
Daniel@0 34
Daniel@0 35 switch net.outfn
Daniel@0 36 case 'linear'
Daniel@0 37 y = rbffwd(net, x);
Daniel@0 38 edata = 0.5*sum(sum((y - t).^2));
Daniel@0 39 case 'neuroscale'
Daniel@0 40 y = rbffwd(net, x);
Daniel@0 41 y_dist = sqrt(dist2(y, y));
Daniel@0 42 % Take t as target distance matrix
Daniel@0 43 edata = 0.5.*(sum(sum((t-y_dist).^2)));
Daniel@0 44 otherwise
Daniel@0 45 error(['Unknown output function ', net.outfn]);
Daniel@0 46 end
Daniel@0 47
Daniel@0 48 % Compute Bayesian regularised error
Daniel@0 49 [e, edata, eprior] = errbayes(net, edata);
Daniel@0 50