wolffd@0: function net = glmunpak(net, w) wolffd@0: %GLMUNPAK Separates weights vector into weight and bias matrices. wolffd@0: % wolffd@0: % Description wolffd@0: % NET = GLMUNPAK(NET, W) takes a glm 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 first-layer weight matrix W1 and wolffd@0: % the first-layer bias vector B1 have been set to the corresponding wolffd@0: % elements of W. wolffd@0: % wolffd@0: % See also wolffd@0: % GLM, GLMPAK, GLMFWD, GLMERR, GLMGRAD 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, 'glm'); wolffd@0: if ~errstring wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: if net.nwts ~= length(w) wolffd@0: error('Invalid weight vector length') wolffd@0: end wolffd@0: wolffd@0: nin = net.nin; wolffd@0: nout = net.nout; wolffd@0: net.w1 = reshape(w(1:nin*nout), nin, nout); wolffd@0: net.b1 = reshape(w(nin*nout + 1: (nin + 1)*nout), 1, nout);