annotate toolboxes/FullBNT-1.0.7/netlab3.3/mdninit.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function net = mdninit(net, prior, t, options)
Daniel@0 2 %MDNINIT Initialise the weights in a Mixture Density Network.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 %
Daniel@0 6 % NET = MDNINIT(NET, PRIOR) takes a Mixture Density Network NET and
Daniel@0 7 % sets the weights and biases by sampling from a Gaussian distribution.
Daniel@0 8 % It calls MLPINIT for the MLP component of NET.
Daniel@0 9 %
Daniel@0 10 % NET = MDNINIT(NET, PRIOR, T, OPTIONS) uses the target data T to
Daniel@0 11 % initialise the biases for the output units after initialising the
Daniel@0 12 % other weights as above. It calls GMMINIT, with T and OPTIONS as
Daniel@0 13 % arguments, to obtain a model of the unconditional density of T. The
Daniel@0 14 % biases are then set so that NET will output the values in the
Daniel@0 15 % Gaussian mixture model.
Daniel@0 16 %
Daniel@0 17 % See also
Daniel@0 18 % MDN, MLP, MLPINIT, GMMINIT
Daniel@0 19 %
Daniel@0 20
Daniel@0 21 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 22 % David J Evans (1998)
Daniel@0 23
Daniel@0 24 % Initialise network weights from prior: this gives noise around values
Daniel@0 25 % determined later
Daniel@0 26 net.mlp = mlpinit(net.mlp, prior);
Daniel@0 27
Daniel@0 28 if nargin > 2
Daniel@0 29 % Initialise priors, centres and variances from target data
Daniel@0 30 temp_mix = gmm(net.mdnmixes.dim_target, net.mdnmixes.ncentres, 'spherical');
Daniel@0 31 temp_mix = gmminit(temp_mix, t, options);
Daniel@0 32
Daniel@0 33 ncentres = net.mdnmixes.ncentres;
Daniel@0 34 dim_target = net.mdnmixes.dim_target;
Daniel@0 35
Daniel@0 36 % Now set parameters in MLP to yield the right values.
Daniel@0 37 % This involves setting the biases correctly.
Daniel@0 38
Daniel@0 39 % Priors
Daniel@0 40 net.mlp.b2(1:ncentres) = temp_mix.priors;
Daniel@0 41
Daniel@0 42 % Centres are arranged in mlp such that we have
Daniel@0 43 % u11, u12, u13, ..., u1c, ... , uj1, uj2, uj3, ..., ujc, ..., um1, uM2,
Daniel@0 44 % ..., uMc
Daniel@0 45 % This is achieved by transposing temp_mix.centres before reshaping
Daniel@0 46 end_centres = ncentres*(dim_target+1);
Daniel@0 47 net.mlp.b2(ncentres+1:end_centres) = ...
Daniel@0 48 reshape(temp_mix.centres', 1, ncentres*dim_target);
Daniel@0 49
Daniel@0 50 % Variances
Daniel@0 51 net.mlp.b2((end_centres+1):net.mlp.nout) = ...
Daniel@0 52 log(temp_mix.covars);
Daniel@0 53 end