From 438c194ec61b34b377727c97d5922897546c581d Mon Sep 17 00:00:00 2001 From: Matthias Treder Date: Mon, 5 Sep 2022 11:16:25 -0700 Subject: [PATCH] stratified_sampling argument: set default to None (#1324) Summary: The self._stratified_sampling attribute is always overridden unless stratified_sampling is explicitly set to None. However, the desired default behavior is that the value of self._stratified_sampling is used unless the argument stratified_sampling is set to True/False. Changing the default to None achieves this Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/1324 Reviewed By: bottler Differential Revision: D39259775 Pulled By: davnov134 fbshipit-source-id: e01bb747ac80c812eb27bf22e67f5e14f29acadd --- pytorch3d/renderer/implicit/raysampling.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pytorch3d/renderer/implicit/raysampling.py b/pytorch3d/renderer/implicit/raysampling.py index 03b096c6..8d594465 100644 --- a/pytorch3d/renderer/implicit/raysampling.py +++ b/pytorch3d/renderer/implicit/raysampling.py @@ -124,7 +124,7 @@ class MultinomialRaysampler(torch.nn.Module): max_depth: Optional[float] = None, n_rays_per_image: Optional[int] = None, n_pts_per_ray: Optional[int] = None, - stratified_sampling: bool = False, + stratified_sampling: Optional[bool] = None, **kwargs, ) -> RayBundle: """ @@ -313,7 +313,11 @@ class MonteCarloRaysampler(torch.nn.Module): self._stratified_sampling = stratified_sampling def forward( - self, cameras: CamerasBase, *, stratified_sampling: bool = False, **kwargs + self, + cameras: CamerasBase, + *, + stratified_sampling: Optional[bool] = None, + **kwargs, ) -> RayBundle: """ Args: