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