annotate toolboxes/FullBNT-1.0.7/netlab3.3/glmunpak.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function net = glmunpak(net, w)
Daniel@0 2 %GLMUNPAK Separates weights vector into weight and bias matrices.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % NET = GLMUNPAK(NET, W) takes a glm network data structure NET and a
Daniel@0 6 % weight vector W, and returns a network data structure identical to
Daniel@0 7 % the input network, except that the first-layer weight matrix W1 and
Daniel@0 8 % the first-layer bias vector B1 have been set to the corresponding
Daniel@0 9 % elements of W.
Daniel@0 10 %
Daniel@0 11 % See also
Daniel@0 12 % GLM, GLMPAK, GLMFWD, GLMERR, GLMGRAD
Daniel@0 13 %
Daniel@0 14
Daniel@0 15 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 16
Daniel@0 17 % Check arguments for consistency
Daniel@0 18 errstring = consist(net, 'glm');
Daniel@0 19 if ~errstring
Daniel@0 20 error(errstring);
Daniel@0 21 end
Daniel@0 22
Daniel@0 23 if net.nwts ~= length(w)
Daniel@0 24 error('Invalid weight vector length')
Daniel@0 25 end
Daniel@0 26
Daniel@0 27 nin = net.nin;
Daniel@0 28 nout = net.nout;
Daniel@0 29 net.w1 = reshape(w(1:nin*nout), nin, nout);
Daniel@0 30 net.b1 = reshape(w(nin*nout + 1: (nin + 1)*nout), 1, nout);