W3cubDocs

/PyTorch 2.9

torch.nn.functional.gaussian_nll_loss

torch.nn.functional.gaussian_nll_loss(input, target, var, full=False, eps=1e-06, reduction='mean') [source]

Compute the Gaussian negative log likelihood loss.

See GaussianNLLLoss for details.

Parameters
  • input (Tensor) – Expectation of the Gaussian distribution.
  • target (Tensor) – Sample from the Gaussian distribution.
  • var (Union[Tensor, float]) – Tensor of positive variance(s), one for each of the expectations in the input (heteroscedastic), or a single one (homoscedastic), or a positive scalar value to be used for all expectations.
  • full (bool, optional) – Whether to include the constant term in the loss calculation. Default: False.
  • eps (float, optional) – Value added to var, for stability. Default: 1e-6.
  • reduction (str, optional) – Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the output is the average of all batch member losses, 'sum': the output is the sum of all batch member losses. Default: 'mean'.
Return type

Tensor

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.nn.functional.gaussian_nll_loss.html