Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/netunpak.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function net = netunpak(net, w) | |
2 %NETUNPAK Separates weights vector into weight and bias matrices. | |
3 % | |
4 % Description | |
5 % NET = NETUNPAK(NET, W) takes an net network data structure NET and a | |
6 % weight vector W, and returns a network data structure identical to | |
7 % the input network, except that the componenet weight matrices have | |
8 % all been set to the corresponding elements of W. If there is a MASK | |
9 % field in the NET data structure, then the weights in W are placed in | |
10 % locations corresponding to non-zero entries in the mask (so W should | |
11 % have the same length as the number of non-zero entries in the MASK). | |
12 % | |
13 % See also | |
14 % NETPAK, NETFWD, NETERR, NETGRAD | |
15 % | |
16 | |
17 % Copyright (c) Ian T Nabney (1996-2001) | |
18 | |
19 unpakstr = [net.type, 'unpak']; | |
20 | |
21 % Check if we are being passed a masked set of weights | |
22 if (isfield(net, 'mask')) | |
23 if length(w) ~= size(find(net.mask), 1) | |
24 error('Weight vector length does not match mask length') | |
25 end | |
26 % Do a full pack of all current network weights | |
27 pakstr = [net.type, 'pak']; | |
28 fullw = feval(pakstr, net); | |
29 % Replace current weights with new ones | |
30 fullw(logical(net.mask)) = w; | |
31 w = fullw; | |
32 end | |
33 | |
34 net = feval(unpakstr, net, w); |