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