Skip to content

Commit

Permalink
Minor bugfix in sample_pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
krrish94 authored Apr 14, 2020
1 parent f913df5 commit 581ea38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions run_nerf_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
return samples

0 comments on commit 581ea38

Please sign in to comment.