<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/nn.py#L2760-L2808) |

Peak Signal-to-Noise Ratio (PSNR) function.

#### View aliases


**Main aliases**

[`tf.keras.ops.nn.psnr`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/psnr)

<br />

    tf.keras.ops.psnr(
        x1, x2, max_val
    )

This function computes the Peak Signal-to-Noise Ratio between two signals,
`x1` and `x2`. PSNR is a measure of the quality of a reconstructed signal.
The higher the PSNR, the closer the reconstructed signal is to the original
signal. Note that it can become negative when the signal power is
smaller that the noise power.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x1` | The first input signal. |
| `x2` | The second input signal. Must have the same shape as `x1`. |
| `max_val` | The maximum possible value in the signals. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `float` | The PSNR value between `x1` and `x2`. |

<br />

#### Examples:

    x1 = keras.random.normal((2, 4, 4, 3))
    x2 = keras.random.normal((2, 4, 4, 3))
    max_val = 1.0
    keras.ops.nn.psnr(x1, x2, max_val)
    -3.1697404