Commit 6e24b953 authored by Yuxin Wu's avatar Yuxin Wu

change psnr_loss to psnr

parent 6686212e
...@@ -148,8 +148,8 @@ def get_scalar_var(name, init_value, summary=False, trainable=False): ...@@ -148,8 +148,8 @@ def get_scalar_var(name, init_value, summary=False, trainable=False):
return ret return ret
def psnr_loss(prediction, ground_truth, name='psnr_loss'): def psnr(prediction, ground_truth, name='psnr'):
"""Negative `Peek Signal to Noise Ratio <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_. """`Peek Signal to Noise Ratio <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.
.. math:: .. math::
...@@ -163,7 +163,7 @@ def psnr_loss(prediction, ground_truth, name='psnr_loss'): ...@@ -163,7 +163,7 @@ def psnr_loss(prediction, ground_truth, name='psnr_loss'):
ground_truth: another :class:`tf.Tensor` with the same shape. ground_truth: another :class:`tf.Tensor` with the same shape.
Returns: Returns:
A scalar tensor. The negative PSNR (for minimization). A scalar tensor representing the PSNR.
""" """
def log10(x): def log10(x):
...@@ -172,7 +172,7 @@ def psnr_loss(prediction, ground_truth, name='psnr_loss'): ...@@ -172,7 +172,7 @@ def psnr_loss(prediction, ground_truth, name='psnr_loss'):
return numerator / denominator return numerator / denominator
return tf.multiply(log10(tf.reduce_mean(tf.square(prediction - ground_truth))), return tf.multiply(log10(tf.reduce_mean(tf.square(prediction - ground_truth))),
10., name=name) -10., name=name)
@contextmanager @contextmanager
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment