Shortcuts

pytorch_lightning.metrics.functional.regression module

pytorch_lightning.metrics.functional.regression.mae(pred, target, reduction='elementwise_mean')[source]

Computes mean absolute error

Parameters
  • pred (Tensor) – estimated labels

  • target (Tensor) – ground truth labels

  • reduction (str) –

    method for reducing mae (default: takes the mean) Available reduction methods:

    • elementwise_mean: takes the mean

    • none: pass array

    • sum: add elements

Return type

Tensor

Returns

Tensor with MAE

Example

>>> x = torch.tensor([0., 1, 2, 3])
>>> y = torch.tensor([0., 1, 2, 2])
>>> mae(x, y)
tensor(0.2500)
pytorch_lightning.metrics.functional.regression.mse(pred, target, reduction='elementwise_mean')[source]

Computes mean squared error

Parameters
  • pred (Tensor) – estimated labels

  • target (Tensor) – ground truth labels

  • reduction (str) –

    method for reducing mse (default: takes the mean) Available reduction methods:

    • elementwise_mean: takes the mean

    • none: pass array

    • sum: add elements

Return type

Tensor

Returns

Tensor with MSE

Example

>>> x = torch.tensor([0., 1, 2, 3])
>>> y = torch.tensor([0., 1, 2, 2])
>>> mse(x, y)
tensor(0.2500)
pytorch_lightning.metrics.functional.regression.psnr(pred, target, data_range=None, base=10.0, reduction='elementwise_mean')[source]

Computes the peak signal-to-noise ratio

Parameters
  • pred (Tensor) – estimated signal

  • target (Tensor) – groun truth signal

  • data_range (Optional[float]) – the range of the data. If None, it is determined from the data (max - min)

  • base (float) – a base of a logarithm to use (default: 10)

  • reduction (str) –

    method for reducing psnr (default: takes the mean) Available reduction methods:

    • elementwise_mean: takes the mean

    • none: pass array

    • sum add elements

Return type

Tensor

Returns

Tensor with PSNR score

Example

>>> from pytorch_lightning.metrics.regression import PSNR
>>> pred = torch.tensor([[0.0, 1.0], [2.0, 3.0]])
>>> target = torch.tensor([[3.0, 2.0], [1.0, 0.0]])
>>> metric = PSNR()
>>> metric(pred, target)
tensor(2.5527)
pytorch_lightning.metrics.functional.regression.rmse(pred, target, reduction='elementwise_mean')[source]

Computes root mean squared error

Parameters
  • pred (Tensor) – estimated labels

  • target (Tensor) – ground truth labels

  • reduction (str) –

    method for reducing rmse (default: takes the mean) Available reduction methods:

    • elementwise_mean: takes the mean

    • none: pass array

    • sum: add elements

Return type

Tensor

Returns

Tensor with RMSE

>>> x = torch.tensor([0., 1, 2, 3])
>>> y = torch.tensor([0., 1, 2, 2])
>>> rmse(x, y)
tensor(0.5000)

pytorch_lightning.metrics.functional.regression.rmsle(pred, target, reduction='elementwise_mean')[source]

Computes root mean squared log error

Parameters
  • pred (Tensor) – estimated labels

  • target (Tensor) – ground truth labels

  • reduction (str) –

    method for reducing rmsle (default: takes the mean) Available reduction methods:

    • elementwise_mean: takes the mean

    • none: pass array

    • sum: add elements

Return type

Tensor

Returns

Tensor with RMSLE

Example

>>> x = torch.tensor([0., 1, 2, 3])
>>> y = torch.tensor([0., 1, 2, 2])
>>> rmsle(x, y)
tensor(0.0207)