def test_reduction_for_dim_none(reduction): match = f"The `reduction={reduction}` will not have any effect when `dim` is None." with pytest.warns(UserWarning, match=match): PSNR(reduction=reduction, dim=None) with pytest.warns(UserWarning, match=match): psnr(_inputs[0].preds, _inputs[0].target, reduction=reduction, dim=None)
def supervised(self, gt, rend): (gt_rgb, gt_alpha), (rend_rgb, rend_alpha) = self._split(gt, rend) gt, rend = gt_rgb * gt_alpha, rend_rgb * rend_alpha return -torch.stack( [metrics.psnr(r, g, data_range=1) for r, g in zip(rend, gt)] )
def reconstruction(self, reconst, inputs): return -torch.stack( [metrics.psnr(r, i, data_range=1) for r, i in zip(reconst, inputs)] )
def test_missing_data_range(): with pytest.raises(ValueError): PSNR(data_range=None, dim=0) with pytest.raises(ValueError): psnr(_inputs[0].preds, _inputs[0].target, data_range=None, dim=0)