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