Open ladzin opened 4 months ago
Code explain from copilot:
In the code you provided, the variable screenspace_points is initialized as a tensor filled with zeros, having the same dimensions as pc.get_xyz. The expression torch.zeros_like(pc.get_xyz, dtype=pc.get_xyz.dtype, requires_grad=True, device="cuda") creates a tensor filled with zeros, matching the dimensions and data type of pc.get_xyz. The + 0 at the end does not affect the value of the tensor, as adding zero does not change the result. We can simplify it to:
Python
screenspace_points = torch.zeros_like(pc.get_xyz, dtype=pc.get_xyz.dtype, requires_grad=True, device="cuda")
Kod wygenerowany przez sztuczną inteligencję. Przejrzyj i używaj uważnie. [Więcej informacji w Często zadawanych pytaniach](https://www.bing.com/new#faq).
The value of screenspace_points will now be a tensor of zeros with the same dimensions as pc.get_xyz, with gradients tracked (parameter requires_grad=True) and stored on the CUDA device (parameter device="cuda"). Sometimes, programmers add + 0 at the end to explicitly show that the variable is initialized as zero, but in this case, it has no impact on the result. 😊
@ladzin after +0, screenspace_points.is_leaf = False, and we should add screenspace_points.retain_grad()
So why bother with +0
?
Why is the "+ 0" here?
https://github.com/graphdeco-inria/gaussian-splatting/blob/472689c0dc70417448fb451bf529ae532d32c095/gaussian_renderer/__init__.py#L26