wolffd@0: function [e, edata, eprior] = rbferr(net, x, t) wolffd@0: %RBFERR Evaluate error function for RBF network. wolffd@0: % wolffd@0: % Description wolffd@0: % E = RBFERR(NET, X, T) takes a network data structure NET together wolffd@0: % with a matrix X of input vectors and a matrix T of target vectors, wolffd@0: % and evaluates the appropriate error function E depending on wolffd@0: % NET.OUTFN. Each row of X corresponds to one input vector and each wolffd@0: % row of T contains the corresponding target vector. wolffd@0: % wolffd@0: % [E, EDATA, EPRIOR] = RBFERR(NET, X, T) additionally returns the data wolffd@0: % and prior components of the error, assuming a zero mean Gaussian wolffd@0: % prior on the weights with inverse variance parameters ALPHA and BETA wolffd@0: % taken from the network data structure NET. wolffd@0: % wolffd@0: % See also wolffd@0: % RBF, RBFFWD, RBFGRAD, RBFPAK, RBFTRAIN, RBFUNPAK wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: switch net.outfn wolffd@0: case 'linear' wolffd@0: errstring = consist(net, 'rbf', x, t); wolffd@0: case 'neuroscale' wolffd@0: errstring = consist(net, 'rbf', x); wolffd@0: otherwise wolffd@0: error(['Unknown output function ', net.outfn]); wolffd@0: end wolffd@0: if ~isempty(errstring); wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: switch net.outfn wolffd@0: case 'linear' wolffd@0: y = rbffwd(net, x); wolffd@0: edata = 0.5*sum(sum((y - t).^2)); wolffd@0: case 'neuroscale' wolffd@0: y = rbffwd(net, x); wolffd@0: y_dist = sqrt(dist2(y, y)); wolffd@0: % Take t as target distance matrix wolffd@0: edata = 0.5.*(sum(sum((t-y_dist).^2))); wolffd@0: otherwise wolffd@0: error(['Unknown output function ', net.outfn]); wolffd@0: end wolffd@0: wolffd@0: % Compute Bayesian regularised error wolffd@0: [e, edata, eprior] = errbayes(net, edata); wolffd@0: