tf.keras.ops.psnr  |  TensorFlow v2.16.1 (original) (raw)

tf.keras.ops.psnr

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

View aliases

Main aliases

tf.keras.ops.nn.psnr

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.

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.
Returns
float The PSNR value between x1 and x2.

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.

Last updated 2024-06-07 UTC.