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