wolffd@0: function w = netpak(net) wolffd@0: %NETPAK Combines weights and biases into one weights vector. wolffd@0: % wolffd@0: % Description wolffd@0: % W = NETPAK(NET) takes a network data structure NET and combines the wolffd@0: % component weight matrices into a single row vector W. The facility wolffd@0: % to switch between these two representations for the network wolffd@0: % parameters is useful, for example, in training a network by error wolffd@0: % function minimization, since a single vector of parameters can be wolffd@0: % handled by general-purpose optimization routines. This function also wolffd@0: % takes into account a MASK defined as a field in NET by removing any wolffd@0: % weights that correspond to entries of 0 in the mask. wolffd@0: % wolffd@0: % See also wolffd@0: % NET, NETUNPAK, NETFWD, NETERR, NETGRAD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: pakstr = [net.type, 'pak']; wolffd@0: w = feval(pakstr, net); wolffd@0: % Return masked subset of weights wolffd@0: if (isfield(net, 'mask')) wolffd@0: w = w(logical(net.mask)); wolffd@0: end