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'or'mean', loss values are summed up or averaged respectively.- Parameters
x (
Variableornumpy.ndarrayorcupy.ndarray) – Input variable.mean (
Variableornumpy.ndarrayorcupy.ndarray) – A variable representing mean of a Gaussian distribution, \(\mu\).ln_var (
Variableornumpy.ndarrayorcupy.ndarray) – A variable representing logarithm of variance of a Gaussian distribution, \(\log(\sigma^2)\).reduce (str) – Reduction option. Its value must be either
'sum','mean'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'or'mean', the output variable holds a scalar value.- Return type