Shortcuts

pytorch_lightning.metrics.regression module

class pytorch_lightning.metrics.regression.MAE(reduction='elementwise_mean')[source]

Bases: pytorch_lightning.metrics.metric.Metric

Computes the root mean absolute loss or L1-loss.

Example

>>> pred = torch.tensor([0., 1, 2, 3])
>>> target = torch.tensor([0., 1, 2, 2])
>>> metric = MAE()
>>> metric(pred, target)
tensor(0.2500)
Parameters

reduction (str) – a method for reducing mse over labels (default: takes the mean) Available reduction methods: - elementwise_mean: takes the mean - none: pass array - sum: add elements

forward(pred, target)[source]

Actual metric computation

Parameters
  • pred (Tensor) – predicted labels

  • target (Tensor) – ground truth labels

Return type

Tensor

Returns

A Tensor with the mae loss.

_device = None[source]
_dtype = None[source]
class pytorch_lightning.metrics.regression.MSE(reduction='elementwise_mean')[source]

Bases: pytorch_lightning.metrics.metric.Metric

Computes the mean squared loss.

Example

>>> pred = torch.tensor([0., 1, 2, 3])
>>> target = torch.tensor([0., 1, 2, 2])
>>> metric = MSE()
>>> metric(pred, target)
tensor(0.2500)
Parameters

reduction (str) – a method for reducing mse over labels (default: takes the mean) Available reduction methods: - elementwise_mean: takes the mean - none: pass array - sum: add elements

forward(pred, target)[source]

Actual metric computation

Parameters
  • pred (Tensor) – predicted labels

  • target (Tensor) – ground truth labels

Return type

Tensor

Returns

A Tensor with the mse loss.

_device = None[source]
_dtype = None[source]
class pytorch_lightning.metrics.regression.PSNR(data_range=None, base=10, reduction='elementwise_mean')[source]

Bases: pytorch_lightning.metrics.metric.Metric

Computes the peak signal-to-noise ratio

Example

>>> 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)
Parameters
  • data_range (Optional[float]) – the range of the data. If None, it is determined from the data (max - min)

  • base (int) – 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

forward(pred, target)[source]

Actual metric computation

Parameters
  • pred (Tensor) – predicted labels

  • target (Tensor) – ground truth labels

Return type

Tensor

Returns

A Tensor with psnr score.

_device = None[source]
_dtype = None[source]
class pytorch_lightning.metrics.regression.RMSE(reduction='elementwise_mean')[source]

Bases: pytorch_lightning.metrics.metric.Metric

Computes the root mean squared loss.

Example

>>> pred = torch.tensor([0., 1, 2, 3])
>>> target = torch.tensor([0., 1, 2, 2])
>>> metric = RMSE()
>>> metric(pred, target)
tensor(0.5000)
Parameters

reduction (str) – a method for reducing mse over labels (default: takes the mean) Available reduction methods: - elementwise_mean: takes the mean - none: pass array - sum: add elements

forward(pred, target)[source]

Actual metric computation

Parameters
  • pred (Tensor) – predicted labels

  • target (Tensor) – ground truth labels

Return type

Tensor

Returns

A Tensor with the rmse loss.

_device = None[source]
_dtype = None[source]
class pytorch_lightning.metrics.regression.RMSLE(reduction='elementwise_mean')[source]

Bases: pytorch_lightning.metrics.metric.Metric

Computes the root mean squared log loss.

Example

>>> pred = torch.tensor([0., 1, 2, 3])
>>> target = torch.tensor([0., 1, 2, 2])
>>> metric = RMSLE()
>>> metric(pred, target)
tensor(0.0207)
Parameters

reduction (str) – a method for reducing mse over labels (default: takes the mean) Available reduction methods: - elementwise_mean: takes the mean - none: pass array - sum: add elements

forward(pred, target)[source]

Actual metric computation

Parameters
  • pred (Tensor) – predicted labels

  • target (Tensor) – ground truth labels

Return type

Tensor

Returns

A Tensor with the rmsle loss.

_device = None[source]
_dtype = None[source]