Shortcuts

torch.nn.functional.mse_loss

torch.nn.functional.mse_loss(input, target, size_average=None, reduce=None, reduction='mean', weight=None) Tensor[source][source]

Measures the element-wise mean squared error, with optional weighting.

Parameters
  • input (Tensor) – Predicted values.

  • target (Tensor) – Ground truth values.

  • size_average (bool, optional) – Deprecated (use reduction).

  • reduce (bool, optional) – Deprecated (use reduction).

  • reduction (str, optional) – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘mean’: the mean of the output is taken. ‘sum’: the output will be summed. ‘none’: no reduction will be applied. Default: ‘mean’.

  • weight (Tensor, optional) – Weights for each sample. Default: None.

Returns

Mean Squared Error loss (optionally weighted).

Return type

Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources