• Docs >
• Relative Average Spectral Error (RASE)
Shortcuts

# Relative Average Spectral Error (RASE)¶

## Module Interface¶

class torchmetrics.image.RelativeAverageSpectralError(window_size=8, **kwargs)[source]

Computes Relative Average Spectral Error (RASE) (RelativeAverageSpectralError).

As input to forward and update the metric accepts the following input

As output of forward and compute the metric returns the following output

• rase (Tensor): returns float scalar tensor with average RASE value over sample

Parameters:
Returns:

Relative Average Spectral Error (RASE)

Example

>>> from torch import rand
>>> preds = rand(4, 3, 16, 16)
>>> target = rand(4, 3, 16, 16)
>>> rase = RelativeAverageSpectralError()
>>> rase(preds, target)
tensor(5326.40...)

Raises:

ValueError – If window_size is not a positive integer.

plot(val=None, ax=None)[source]

Plot a single or multiple values from the metric.

Parameters:
Return type:
Returns:

Figure and Axes object

Raises:

ModuleNotFoundError – If matplotlib is not installed

>>> # Example plotting a single value
>>> import torch
>>> from torchmetrics.image import RelativeAverageSpectralError
>>> metric = RelativeAverageSpectralError()
>>> metric.update(torch.rand(4, 3, 16, 16), torch.rand(4, 3, 16, 16))
>>> fig_, ax_ = metric.plot()

>>> # Example plotting multiple values
>>> from torch import rand
>>> from torchmetrics.image import RelativeAverageSpectralError
>>> metric = RelativeAverageSpectralError()
>>> values = [ ]
>>> for _ in range(10):
...     values.append(metric(rand(4, 3, 16, 16), rand(4, 3, 16, 16)))
>>> fig_, ax_ = metric.plot(values)


## Functional Interface¶

torchmetrics.functional.image.relative_average_spectral_error(preds, target, window_size=8)[source]

Compute Relative Average Spectral Error (RASE) (RelativeAverageSpectralError).

Parameters:
Return type:

Tensor

Returns:

Relative Average Spectral Error (RASE)

Example

>>> from torch import rand
>>> from torchmetrics.functional.image import relative_average_spectral_error
>>> preds = rand(4, 3, 16, 16)
>>> target = rand(4, 3, 16, 16)
>>> relative_average_spectral_error(preds, target)
tensor(5326.40...)

Raises:

ValueError – If window_size is not a positive integer.