pytorch_lightning.metrics.functional.regression module¶
-
pytorch_lightning.metrics.functional.regression.
_gaussian_kernel
(channel, kernel_size, sigma, device)[source]¶
-
pytorch_lightning.metrics.functional.regression.
mae
(pred, target, reduction='elementwise_mean')[source]¶ Computes mean absolute error
- Parameters
- Return type
- 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
- Return type
- 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
- Return type
- 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
- Return type
- 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
- Return type
- 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)
-
pytorch_lightning.metrics.functional.regression.
ssim
(pred, target, kernel_size=(11, 11), sigma=(1.5, 1.5), reduction='elementwise_mean', data_range=None, k1=0.01, k2=0.03)[source]¶ Computes Structual Similarity Index Measure
- Parameters
kernel_size¶ (
Sequence
[int
]) – size of the gaussian kernel (default: (11, 11))sigma¶ (
Sequence
[float
]) – Standard deviation of the gaussian kernel (default: (1.5, 1.5))a method to reduce metric score over labels (default: takes the mean) Available reduction methods:
elementwise_mean: takes the mean
none: pass away
sum: add elements
data_range¶ (
Optional
[float
]) – Range of the image. IfNone
, it is determined from the image (max - min)
- Return type
- Returns
Tensor with SSIM score
Example
>>> pred = torch.rand([16, 1, 16, 16]) >>> target = pred * 0.75 >>> ssim(pred, target) tensor(0.9219)