def gaussian_nll(x, mean, ln_var):
 assert isinstance(x, variable.Variable)
 assert isinstance(mean, variable.Variable)
 assert isinstance(ln_var, variable.Variable)
 D = x.size
 x_prec = exponential.exp((- ln_var))
 x_diff = (x - mean)
 x_power = (((x_diff * x_diff) * x_prec) * (-0.5))
 return (((sum.sum(ln_var) + (D * math.log((2 * math.pi)))) / 2) - sum.sum(x_power))

def gaussian_nll ( x , mean , ln_var ) : assert isinstance ( x , variable . Variable ) assert isinstance ( mean , variable . Variable ) assert isinstance ( ln_var , variable . Variable ) D = x . size x_prec = exponential . exp ( ( - ln_var ) ) x_diff = ( x - mean ) x_power = ( ( ( x_diff * x_diff ) * x_prec ) * ( - 0.5 ) ) return ( ( ( sum . sum ( ln_var ) + ( D * math . log ( ( 2 * math . pi ) ) ) ) / 2 ) - sum . sum ( x_power ) )
computes the negative log-likelihood of a gaussian distribution .