From 581ea38d783fe49fc7843b58cdf88f45d93a4c22 Mon Sep 17 00:00:00 2001 From: Krishna Murthy Date: Tue, 14 Apr 2020 14:52:54 -0400 Subject: [PATCH] Minor bugfix in sample_pdf --- run_nerf_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_nerf_helpers.py b/run_nerf_helpers.py index 70f2828..3c68271 100644 --- a/run_nerf_helpers.py +++ b/run_nerf_helpers.py @@ -225,7 +225,7 @@ def sample_pdf(bins, weights, N_samples, det=False, pytest=False): u = u.contiguous() inds = searchsorted(cdf, u, side='right') below = torch.max(torch.zeros_like(inds-1), inds-1) - above = torch.min(cdf.shape[-1]-1 * torch.ones_like(inds), inds) + above = torch.min((cdf.shape[-1]-1) * torch.ones_like(inds), inds) inds_g = torch.stack([below, above], -1) # (batch, N_samples, 2) # cdf_g = tf.gather(cdf, inds_g, axis=-1, batch_dims=len(inds_g.shape)-2) @@ -239,4 +239,4 @@ def sample_pdf(bins, weights, N_samples, det=False, pytest=False): t = (u-cdf_g[...,0])/denom samples = bins_g[...,0] + t * (bins_g[...,1]-bins_g[...,0]) - return samples \ No newline at end of file + return samples