annotate toolboxes/FullBNT-1.0.7/netlab3.3/mdn.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function net = mdn(nin, nhidden, ncentres, dim_target, mix_type, ...
wolffd@0 2 prior, beta)
wolffd@0 3 %MDN Creates a Mixture Density Network with specified architecture.
wolffd@0 4 %
wolffd@0 5 % Description
wolffd@0 6 % NET = MDN(NIN, NHIDDEN, NCENTRES, DIMTARGET) takes the number of
wolffd@0 7 % inputs, hidden units for a 2-layer feed-forward network and the
wolffd@0 8 % number of centres and target dimension for the mixture model whose
wolffd@0 9 % parameters are set from the outputs of the neural network. The fifth
wolffd@0 10 % argument MIXTYPE is used to define the type of mixture model.
wolffd@0 11 % (Currently there is only one type supported: a mixture of Gaussians
wolffd@0 12 % with a single covariance parameter for each component.) For this
wolffd@0 13 % model, the mixture coefficients are computed from a group of softmax
wolffd@0 14 % outputs, the centres are equal to a group of linear outputs, and the
wolffd@0 15 % variances are obtained by applying the exponential function to a
wolffd@0 16 % third group of outputs.
wolffd@0 17 %
wolffd@0 18 % The network is initialised by a call to MLP, and the arguments PRIOR,
wolffd@0 19 % and BETA have the same role as for that function. Weight
wolffd@0 20 % initialisation uses the Matlab function RANDN and so the seed for
wolffd@0 21 % the random weight initialization can be set using RANDN('STATE', S)
wolffd@0 22 % where S is the seed value. A specialised data structure (rather than
wolffd@0 23 % GMM) is used for the mixture model outputs to improve the efficiency
wolffd@0 24 % of error and gradient calculations in network training. The fields
wolffd@0 25 % are described in MDNFWD where they are set up.
wolffd@0 26 %
wolffd@0 27 % The fields in NET are
wolffd@0 28 %
wolffd@0 29 % type = 'mdn'
wolffd@0 30 % nin = number of input variables
wolffd@0 31 % nout = dimension of target space (not number of network outputs)
wolffd@0 32 % nwts = total number of weights and biases
wolffd@0 33 % mdnmixes = data structure for mixture model output
wolffd@0 34 % mlp = data structure for MLP network
wolffd@0 35 %
wolffd@0 36 % See also
wolffd@0 37 % MDNFWD, MDNERR, MDN2GMM, MDNGRAD, MDNPAK, MDNUNPAK, MLP
wolffd@0 38 %
wolffd@0 39
wolffd@0 40 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 41 % David J Evans (1998)
wolffd@0 42
wolffd@0 43 % Currently ignore type argument: reserved for future use
wolffd@0 44 net.type = 'mdn';
wolffd@0 45
wolffd@0 46 % Set up the mixture model part of the structure
wolffd@0 47 % For efficiency we use a specialised data structure in place of GMM
wolffd@0 48 mdnmixes.type = 'mdnmixes';
wolffd@0 49 mdnmixes.ncentres = ncentres;
wolffd@0 50 mdnmixes.dim_target = dim_target;
wolffd@0 51
wolffd@0 52 % This calculation depends on spherical variances
wolffd@0 53 mdnmixes.nparams = ncentres + ncentres*dim_target + ncentres;
wolffd@0 54
wolffd@0 55 % Make the weights in the mdnmixes structure null
wolffd@0 56 mdnmixes.mixcoeffs = [];
wolffd@0 57 mdnmixes.centres = [];
wolffd@0 58 mdnmixes.covars = [];
wolffd@0 59
wolffd@0 60 % Number of output nodes = number of parameters in mixture model
wolffd@0 61 nout = mdnmixes.nparams;
wolffd@0 62
wolffd@0 63 % Set up the MLP part of the network
wolffd@0 64 if (nargin == 5)
wolffd@0 65 mlpnet = mlp(nin, nhidden, nout, 'linear');
wolffd@0 66 elseif (nargin == 6)
wolffd@0 67 mlpnet = mlp(nin, nhidden, nout, 'linear', prior);
wolffd@0 68 elseif (nargin == 7)
wolffd@0 69 mlpnet = mlp(nin, nhidden, nout, 'linear', prior, beta);
wolffd@0 70 end
wolffd@0 71
wolffd@0 72 % Create descriptor
wolffd@0 73 net.mdnmixes = mdnmixes;
wolffd@0 74 net.mlp = mlpnet;
wolffd@0 75 net.nin = nin;
wolffd@0 76 net.nout = dim_target;
wolffd@0 77 net.nwts = mlpnet.nwts;