wolffd@0: function e = mdnerr(net, x, t) wolffd@0: %MDNERR Evaluate error function for Mixture Density Network. wolffd@0: % wolffd@0: % Description wolffd@0: % E = MDNERR(NET, X, T) takes a mixture density network data structure wolffd@0: % NET, a matrix X of input vectors and a matrix T of target vectors, wolffd@0: % and evaluates the error function E. The error function is the wolffd@0: % negative log likelihood of the target data under the conditional wolffd@0: % density given by the mixture model parameterised by the MLP. Each wolffd@0: % row of X corresponds to one input vector and each row of T wolffd@0: % corresponds to one target vector. wolffd@0: % wolffd@0: % See also wolffd@0: % MDN, MDNFWD, MDNGRAD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: % David J Evans (1998) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: errstring = consist(net, 'mdn', x, t); wolffd@0: if ~isempty(errstring) wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: % Get the output mixture models wolffd@0: mixparams = mdnfwd(net, x); wolffd@0: wolffd@0: % Compute the probabilities of mixtures wolffd@0: probs = mdnprob(mixparams, t); wolffd@0: % Compute the error wolffd@0: e = sum( -log(max(eps, sum(probs, 2)))); wolffd@0: