Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ 0? #802

Open
ladzin opened this issue May 10, 2024 · 1 comment
Open

+ 0? #802

ladzin opened this issue May 10, 2024 · 1 comment

Comments

@ladzin
Copy link

ladzin commented May 10, 2024

Why is the "+ 0" here?

screenspace_points = torch.zeros_like(pc.get_xyz, dtype=pc.get_xyz.dtype, requires_grad=True, device="cuda") + 0

@jaco001
Copy link

jaco001 commented May 10, 2024

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. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants