annotate toolboxes/FullBNT-1.0.7/netlab3.3/mdnerr.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 e = mdnerr(net, x, t)
wolffd@0 2 %MDNERR Evaluate error function for Mixture Density Network.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % E = MDNERR(NET, X, T) takes a mixture density network data structure
wolffd@0 6 % NET, a matrix X of input vectors and a matrix T of target vectors,
wolffd@0 7 % and evaluates the error function E. The error function is the
wolffd@0 8 % negative log likelihood of the target data under the conditional
wolffd@0 9 % density given by the mixture model parameterised by the MLP. Each
wolffd@0 10 % row of X corresponds to one input vector and each row of T
wolffd@0 11 % corresponds to one target vector.
wolffd@0 12 %
wolffd@0 13 % See also
wolffd@0 14 % MDN, MDNFWD, MDNGRAD
wolffd@0 15 %
wolffd@0 16
wolffd@0 17 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 18 % David J Evans (1998)
wolffd@0 19
wolffd@0 20 % Check arguments for consistency
wolffd@0 21 errstring = consist(net, 'mdn', x, t);
wolffd@0 22 if ~isempty(errstring)
wolffd@0 23 error(errstring);
wolffd@0 24 end
wolffd@0 25
wolffd@0 26 % Get the output mixture models
wolffd@0 27 mixparams = mdnfwd(net, x);
wolffd@0 28
wolffd@0 29 % Compute the probabilities of mixtures
wolffd@0 30 probs = mdnprob(mixparams, t);
wolffd@0 31 % Compute the error
wolffd@0 32 e = sum( -log(max(eps, sum(probs, 2))));
wolffd@0 33