about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/netlab3.3/mdn.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/mdn.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/mdn.m')
-rw-r--r--sourcecodes/bnt-master/netlab3.3/mdn.m77
1 files changed, 77 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/netlab3.3/mdn.m b/sourcecodes/bnt-master/netlab3.3/mdn.m
new file mode 100644
index 00000000..964baa1d
--- /dev/null
+++ b/sourcecodes/bnt-master/netlab3.3/mdn.m
@@ -0,0 +1,77 @@
+function net = mdn(nin, nhidden, ncentres, dim_target, mix_type, ...
+	prior, beta)
+%MDN	Creates a Mixture Density Network with specified architecture.
+%
+%	Description
+%	NET = MDN(NIN, NHIDDEN, NCENTRES, DIMTARGET) takes the number of
+%	inputs,  hidden units for a 2-layer feed-forward  network and the
+%	number of centres and target dimension for the  mixture model whose
+%	parameters are set from the outputs of the neural network. The fifth
+%	argument MIXTYPE is used to define the type of mixture model.
+%	(Currently there is only one type supported: a mixture of Gaussians
+%	with a single covariance parameter for each component.) For this
+%	model, the mixture coefficients are computed from a group of softmax
+%	outputs, the centres are equal to a group of linear outputs, and the
+%	variances are  obtained by applying the exponential function to a
+%	third group of outputs.
+%
+%	The network is initialised by a call to MLP, and the arguments PRIOR,
+%	and BETA have the same role as for that function. Weight
+%	initialisation uses the Matlab function RANDN  and so the seed for
+%	the random weight initialization can be  set using RANDN('STATE', S)
+%	where S is the seed value. A specialised data structure (rather than
+%	GMM) is used for the mixture model outputs to improve the efficiency
+%	of error and gradient calculations in network training. The fields
+%	are described in MDNFWD where they are set up.
+%
+%	The fields in NET are
+%	  
+%	  type = 'mdn'
+%	  nin = number of input variables
+%	  nout = dimension of target space (not number of network outputs)
+%	  nwts = total number of weights and biases
+%	  mdnmixes = data structure for mixture model output
+%	  mlp = data structure for MLP network
+%
+%	See also
+%	MDNFWD, MDNERR, MDN2GMM, MDNGRAD, MDNPAK, MDNUNPAK, MLP
+%
+
+%	Copyright (c) Ian T Nabney (1996-2001)
+%	David J Evans (1998)
+
+% Currently ignore type argument: reserved for future use
+net.type = 'mdn';
+
+% Set up the mixture model part of the structure
+% For efficiency we use a specialised data structure in place of GMM
+mdnmixes.type = 'mdnmixes';
+mdnmixes.ncentres = ncentres;
+mdnmixes.dim_target = dim_target;
+
+% This calculation depends on spherical variances
+mdnmixes.nparams = ncentres + ncentres*dim_target + ncentres;
+
+% Make the weights in the mdnmixes structure null 
+mdnmixes.mixcoeffs = [];
+mdnmixes.centres = [];
+mdnmixes.covars = [];
+
+% Number of output nodes = number of parameters in mixture model
+nout = mdnmixes.nparams;
+
+% Set up the MLP part of the network
+if (nargin == 5)
+  mlpnet = mlp(nin, nhidden, nout, 'linear');
+elseif (nargin == 6)
+  mlpnet = mlp(nin, nhidden, nout, 'linear', prior);
+elseif (nargin == 7)
+  mlpnet = mlp(nin, nhidden, nout, 'linear', prior, beta);
+end
+
+% Create descriptor
+net.mdnmixes = mdnmixes;
+net.mlp = mlpnet;
+net.nin = nin;
+net.nout = dim_target;
+net.nwts = mlpnet.nwts;