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
mean
representing μ andln_var
representing log(σ2), this function computes in elementwise manner the negative log-likelihood of x on a Gaussian distribution N(μ,S),−logN(x;μ,σ2)=log(√(2π)D|S|)+12(x−μ)⊤S−1(x−μ),where D is a dimension of x and S is a diagonal matrix where Sii=σ2i.
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 (
Variable
ornumpy.ndarray
orcupy.ndarray
) – Input variable.mean (
Variable
ornumpy.ndarray
orcupy.ndarray
) – A variable representing mean of a Gaussian distribution, μ.ln_var (
Variable
ornumpy.ndarray
orcupy.ndarray
) – A variable representing logarithm of variance of a Gaussian distribution, log(σ2).reduce (str) – Reduction option. Its value must be either
'sum'
,'mean'
or'no'
. Otherwise,ValueError
is raised.
- Returns
A variable representing the negative log-likelihood. If
reduce
is'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