Esempio n. 1
0
 def compute(self):
     """
     Compute peak signal-to-noise ratio over state.
     """
     if self.data_range is not None:
         data_range = self.data_range
     else:
         data_range = self.max_target - self.min_target
     return _psnr_compute(self.sum_squared_error, self.total, data_range,
                          self.base, self.reduction)
Esempio n. 2
0
    def compute(self):
        """
        Compute peak signal-to-noise ratio over state.
        """
        if self.data_range is not None:
            data_range = self.data_range
        else:
            data_range = self.max_target - self.min_target

        if self.dim is None:
            sum_squared_error = self.sum_squared_error
            total = self.total
        else:
            sum_squared_error = torch.cat(
                [values.flatten() for values in self.sum_squared_error])
            total = torch.cat([values.flatten() for values in self.total])
        return _psnr_compute(sum_squared_error,
                             total,
                             data_range,
                             base=self.base,
                             reduction=self.reduction)