chainer.functions.gaussian_nll¶
-
chainer.functions.gaussian_nll(x, mean, ln_var, reduce='sum')[source]¶ Computes the negative log-likelihood of a Gaussian distribution.
Given two variable
meanrepresenting \(\mu\) andln_varrepresenting \(\log(\sigma^2)\), this function computes in elementwise manner the negative log-likelihood of \(x\) on a Gaussian distribution \(N(\mu, S)\),\[-\log N(x; \mu, \sigma^2) = \log\left(\sqrt{(2\pi)^D |S|}\right) + \frac{1}{2}(x - \mu)^\top S^{-1}(x - \mu),\]where \(D\) is a dimension of \(x\) and \(S\) is a diagonal matrix where \(S_{ii} = \sigma_i^2\).
The output is a variable whose value depends on the value of the option
reduce. If it is'no', it holds the elementwise loss values. If it is'sum', loss values are summed up.Parameters: - x (
Variableor N-dimensional array) – Input variable. - mean (
Variableor N-dimensional array) – A variable representing mean of a Gaussian distribution, \(\mu\). - ln_var (
Variableor N-dimensional array) – A variable representing logarithm of variance of a Gaussian distribution, \(\log(\sigma^2)\). - reduce (str) – Reduction option. Its value must be either
'sum'or'no'. Otherwise,ValueErroris raised.
Returns: A variable representing the negative log-likelihood. If
reduceis'no', the output variable holds array whose shape is same as one of (hence both of) input variables. If it is'sum', the output variable holds a scalar value.Return type: - x (