---
title: Error Relative Global Dim. Synthesis (ERGAS)
description: Calculate the Error relative global dimensionless synthesis  (ERGAS) metric.
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/image/error_relative_global_dimensionless_synthesis
---
# Error Relative Global Dim. Synthesis (ERGAS) {#error-relative-global-dim-synthesis-ergas}

## Module Interface {#module-interface}

### `class torchmetrics.image.ErrorRelativeGlobalDimensionlessSynthesis(ratio=4, reduction='elementwise_mean', **kwargs)` {#torchmetrics.image.ErrorRelativeGlobalDimensionlessSynthesis}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/image/ergas.py#L32-L158)

Calculate the [Error relative global dimensionless synthesis](https://minesparis-psl.hal.science/hal-00464703) (ERGAS) metric.

This metric is used to calculate the accuracy of Pan sharpened image considering normalized average error of each band of the result image. It is defined as:

```math
ERGAS = \frac{100}{r} \cdot \sqrt{\frac{1}{N} \sum_{k=1}^{N} \frac{RMSE(B_k)^2}{\mu_k^2}}
```

where $`r=h/l`$ denote the ratio in spatial resolution (pixel size) between the high and low resolution images. $`N`$ is the number of spectral bands, $`RMSE(B_k)`$ is the root mean square error of the k-th band between low and high resolution images, and $`\\mu_k`$ is the mean value of the k-th band of the reference image.

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

*   `preds` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): Predictions from model
    
*   `target` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): Ground truth values
    

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

*   `ergas` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): if `reduction!='none'` returns float scalar tensor with average ERGAS value over sample else returns tensor of shape `(N,)` with ERGAS values per sample
    

Parameters:

*   **ratio** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – ratio of high resolution to low resolution.
    
*   **reduction** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'elementwise_mean'`, `'sum'`, `'none'`, `None`\]) –
    
    a method to reduce metric score over labels.
    
    *   `'elementwise_mean'`: takes the mean (default)
        
    *   `'sum'`: takes the sum
        
    *   `'none'` or `None`: no reduction will be applied
        
    
*   **kwargs** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Additional keyword arguments, see [Advanced metric settings](/docs/torchmetrics/1.9.0/user-guide/overview.md#metric-kwargs) for more info.
    

Example

```python
>>> from torch import rand
>>> from torchmetrics.image import ErrorRelativeGlobalDimensionlessSynthesis
>>> preds = rand([16, 1, 16, 16])
>>> target = preds * 0.75
>>> ergas = ErrorRelativeGlobalDimensionlessSynthesis()
>>> ergas(preds, target).round()
tensor(10.)
```

#### `plot(val=None, ax=None)` {#torchmetrics.image.ErrorRelativeGlobalDimensionlessSynthesis.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/image/ergas.py#L114-L158)

Plot a single or multiple values from the metric.

Parameters:

*   **val** (`Union`\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)"), [`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\], [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Either a single result from calling metric.forward or metric.compute or a list of these results. If no value is provided, will automatically call metric.compute and plot that result.
    
*   **ax** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)")\]) – An matplotlib axis object. If provided will add plot to that axis
    

Return type:

[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")\[[`Figure`](https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure "(in Matplotlib v3.11.2)"), `Union`\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)"), [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.5)")\]\]

Returns:

Figure and Axes object

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If matplotlib is not installed

```python
>>> # Example plotting a single value
>>> from torch import rand
>>> from torchmetrics.image import ErrorRelativeGlobalDimensionlessSynthesis
>>> preds = rand([16, 1, 16, 16])
>>> target = preds * 0.75
>>> metric = ErrorRelativeGlobalDimensionlessSynthesis()
>>> metric.update(preds, target)
>>> fig_, ax_ = metric.plot()
```

[![../../\_images/error\_relative\_global\_dimensionless\_synthesis-1.png](/docs/torchmetrics/1.9.0/static/_images/error_relative_global_dimensionless_synthesis-1.png)](/docs/torchmetrics/1.9.0/static/_images/error_relative_global_dimensionless_synthesis-1.png)

```python
>>> # Example plotting multiple values
>>> from torch import rand
>>> from torchmetrics.image import ErrorRelativeGlobalDimensionlessSynthesis
>>> preds = rand([16, 1, 16, 16])
>>> target = preds * 0.75
>>> metric = ErrorRelativeGlobalDimensionlessSynthesis()
>>> values = [ ]
>>> for _ in range(10):
...     values.append(metric(preds, target))
>>> fig_, ax_ = metric.plot(values)
```

[![../../\_images/error\_relative\_global\_dimensionless\_synthesis-2.png](/docs/torchmetrics/1.9.0/static/_images/error_relative_global_dimensionless_synthesis-2.png)](/docs/torchmetrics/1.9.0/static/_images/error_relative_global_dimensionless_synthesis-2.png)

## Functional Interface {#functional-interface}

### `torchmetrics.functional.image.error_relative_global_dimensionless_synthesis(preds, target, ratio=4, reduction='elementwise_mean')` {#torchmetrics.functional.image.error_relative_global_dimensionless_synthesis}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/functional/image/ergas.py#L84-L121)

Calculates [Error relative global dimensionless synthesis](https://minesparis-psl.hal.science/hal-00464703) (ERGAS) metric.

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – estimated image
    
*   **target** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – ground truth image
    
*   **ratio** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – ratio of high resolution to low resolution
    
*   **reduction** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'elementwise_mean'`, `'sum'`, `'none'`, `None`\]) –
    
    a method to reduce metric score over labels.
    
    *   `'elementwise_mean'`: takes the mean (default)
        
    *   `'sum'`: takes the sum
        
    *   `'none'` or `None`: no reduction will be applied
        
    

Return type:

[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")

Returns:

Tensor with RelativeG score

Raises:

*   [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError "(in Python v3.15)") – If `preds` and `target` don’t have the same data type.
    
*   [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If `preds` and `target` don’t have `BxCxHxW shape`.
    

Example

```python
>>> from torch import rand
>>> from torchmetrics.functional.image import error_relative_global_dimensionless_synthesis
>>> preds = rand([16, 1, 16, 16])
>>> target = preds * 0.75
>>> error_relative_global_dimensionless_synthesis(preds, target)
tensor(9.6193)
```

---

**Navigation**

- Parent: [Image](/docs/torchmetrics/1.9.0/image.md)
