about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/netlab3.3/mdninit.m
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/netlab3.3/mdninit.m
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/netlab3.3/mdninit.m')
-rw-r--r--sourcecodes/bnt-master/netlab3.3/mdninit.m53
1 files changed, 53 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/netlab3.3/mdninit.m b/sourcecodes/bnt-master/netlab3.3/mdninit.m
new file mode 100644
index 00000000..20f23d0e
--- /dev/null
+++ b/sourcecodes/bnt-master/netlab3.3/mdninit.m
@@ -0,0 +1,53 @@
+function net = mdninit(net, prior, t, options)
+%MDNINIT Initialise the weights in a Mixture Density Network.
+%
+%	Description
+%
+%	NET = MDNINIT(NET, PRIOR) takes a Mixture Density Network NET and
+%	sets the weights and biases by sampling from a Gaussian distribution.
+%	It calls MLPINIT for the MLP component of NET.
+%
+%	NET = MDNINIT(NET, PRIOR, T, OPTIONS) uses the target data T to
+%	initialise the biases for the output units after initialising the
+%	other weights as above.  It calls GMMINIT, with T and OPTIONS as
+%	arguments, to obtain a model of the unconditional density of T.  The
+%	biases are then set so that NET will output the values in the
+%	Gaussian  mixture model.
+%
+%	See also
+%	MDN, MLP, MLPINIT, GMMINIT
+%
+
+%	Copyright (c) Ian T Nabney (1996-2001)
+%	David J Evans (1998)
+
+% Initialise network weights from prior: this gives noise around values
+% determined later
+net.mlp = mlpinit(net.mlp, prior);
+
+if nargin > 2
+  % Initialise priors, centres and variances from target data
+  temp_mix = gmm(net.mdnmixes.dim_target, net.mdnmixes.ncentres, 'spherical');
+  temp_mix = gmminit(temp_mix, t, options);
+  
+  ncentres = net.mdnmixes.ncentres;
+  dim_target = net.mdnmixes.dim_target;
+
+  % Now set parameters in MLP to yield the right values.
+  % This involves setting the biases correctly.
+  
+  % Priors
+  net.mlp.b2(1:ncentres) = temp_mix.priors;
+  
+  % Centres are arranged in mlp such that we have
+  % u11, u12, u13, ..., u1c, ... , uj1, uj2, uj3, ..., ujc, ..., um1, uM2, 
+  % ..., uMc
+  % This is achieved by transposing temp_mix.centres before reshaping
+  end_centres = ncentres*(dim_target+1);
+  net.mlp.b2(ncentres+1:end_centres) = ...
+    reshape(temp_mix.centres', 1, ncentres*dim_target);
+  
+  % Variances
+  net.mlp.b2((end_centres+1):net.mlp.nout) = ...
+    log(temp_mix.covars);
+end