Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/mlpunpak.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 = mlpunpak(net, w) | |
2 %MLPUNPAK Separates weights vector into weight and bias matrices. | |
3 % | |
4 % Description | |
5 % NET = MLPUNPAK(NET, W) takes an mlp 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 first-layer weight matrix W1, the | |
8 % first-layer bias vector B1, the second-layer weight matrix W2 and the | |
9 % second-layer bias vector B2 have all been set to the corresponding | |
10 % elements of W. | |
11 % | |
12 % See also | |
13 % MLP, MLPPAK, MLPFWD, MLPERR, MLPBKP, MLPGRAD | |
14 % | |
15 | |
16 % Copyright (c) Ian T Nabney (1996-2001) | |
17 | |
18 % Check arguments for consistency | |
19 errstring = consist(net, 'mlp'); | |
20 if ~isempty(errstring); | |
21 error(errstring); | |
22 end | |
23 | |
24 if net.nwts ~= length(w) | |
25 error('Invalid weight vector length') | |
26 end | |
27 | |
28 nin = net.nin; | |
29 nhidden = net.nhidden; | |
30 nout = net.nout; | |
31 | |
32 mark1 = nin*nhidden; | |
33 net.w1 = reshape(w(1:mark1), nin, nhidden); | |
34 mark2 = mark1 + nhidden; | |
35 net.b1 = reshape(w(mark1 + 1: mark2), 1, nhidden); | |
36 mark3 = mark2 + nhidden*nout; | |
37 net.w2 = reshape(w(mark2 + 1: mark3), nhidden, nout); | |
38 mark4 = mark3 + nout; | |
39 net.b2 = reshape(w(mark3 + 1: mark4), 1, nout); |