wolffd@0: function net = rbfunpak(net, w) wolffd@0: %RBFUNPAK Separates a vector of RBF weights into its components. wolffd@0: % wolffd@0: % Description wolffd@0: % NET = RBFUNPAK(NET, W) takes an RBF network data structure NET and a wolffd@0: % weight vector W, and returns a network data structure identical to wolffd@0: % the input network, except that the centres C, the widths WI, the wolffd@0: % second-layer weight matrix W2 and the second-layer bias vector B2 wolffd@0: % have all been set to the corresponding elements of W. wolffd@0: % wolffd@0: % See also wolffd@0: % RBFPAK, RBF wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: errstring = consist(net, 'rbf'); wolffd@0: if ~errstring wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: if net.nwts ~= length(w) wolffd@0: error('Invalid length of weight vector') wolffd@0: end wolffd@0: wolffd@0: nin = net.nin; wolffd@0: nhidden = net.nhidden; wolffd@0: nout = net.nout; wolffd@0: wolffd@0: mark1 = nin*nhidden; wolffd@0: net.c = reshape(w(1:mark1), nhidden, nin); wolffd@0: if strcmp(net.actfn, 'gaussian') wolffd@0: mark2 = mark1 + nhidden; wolffd@0: net.wi = reshape(w(mark1+1:mark2), 1, nhidden); wolffd@0: else wolffd@0: mark2 = mark1; wolffd@0: net.wi = []; wolffd@0: end wolffd@0: mark3 = mark2 + nhidden*nout; wolffd@0: net.w2 = reshape(w(mark2+1:mark3), nhidden, nout); wolffd@0: mark4 = mark3 + nout; wolffd@0: net.b2 = reshape(w(mark3+1:mark4), 1, nout);