Daniel@0: function net = glmunpak(net, w) Daniel@0: %GLMUNPAK Separates weights vector into weight and bias matrices. Daniel@0: % Daniel@0: % Description Daniel@0: % NET = GLMUNPAK(NET, W) takes a glm network data structure NET and a Daniel@0: % weight vector W, and returns a network data structure identical to Daniel@0: % the input network, except that the first-layer weight matrix W1 and Daniel@0: % the first-layer bias vector B1 have been set to the corresponding Daniel@0: % elements of W. Daniel@0: % Daniel@0: % See also Daniel@0: % GLM, GLMPAK, GLMFWD, GLMERR, GLMGRAD Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: % Check arguments for consistency Daniel@0: errstring = consist(net, 'glm'); Daniel@0: if ~errstring Daniel@0: error(errstring); Daniel@0: end Daniel@0: Daniel@0: if net.nwts ~= length(w) Daniel@0: error('Invalid weight vector length') Daniel@0: end Daniel@0: Daniel@0: nin = net.nin; Daniel@0: nout = net.nout; Daniel@0: net.w1 = reshape(w(1:nin*nout), nin, nout); Daniel@0: net.b1 = reshape(w(nin*nout + 1: (nin + 1)*nout), 1, nout);