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

Pose optimization for 2dgs? #546

Open
jizongFox opened this issue Jan 22, 2025 · 0 comments
Open

Pose optimization for 2dgs? #546

jizongFox opened this issue Jan 22, 2025 · 0 comments

Comments

@jizongFox
Copy link

Hello,
I happened to compare the pose optimization gradient between 3dgs and 2dgs. I found that viewmat has always 0.0 gradient. A minimal example can be found as blew.

import torch

from gsplat import rasterization_2dgs

device = torch.device("cuda:0")

means = torch.randn((1000, 3), device=device, requires_grad=True)
quats = torch.randn((1000, 4), device=device, requires_grad=True)
scales = torch.rand((1000, 3), device=device, requires_grad=True) * 0.1
colors = torch.rand((1000, 3), device=device, requires_grad=True)
opacities = torch.rand((1000,), device=device, requires_grad=True)
# define cameras
viewmats = torch.eye(4, device=device)[None, :, :]
viewmats.requires_grad = True
Ks = torch.tensor(
    [[300.0, 0.0, 150.0], [0.0, 300.0, 100.0], [0.0, 0.0, 1.0]],
    device=device,
    requires_grad=True,
)[None, :, :]
width, height = 300, 200
# render
colors, alphas, normals, surf_normals, distort, median_depth, meta = (
    rasterization_2dgs(
        means, quats, scales, opacities, colors, viewmats, Ks, width, height
    )
)
loss = colors.mean()
loss.backward()

print("Gradients of means:", means.grad)
print("Gradients of quats:", quats.grad)
print("Gradients of scales:", scales.grad)
print("Gradients of colors:", colors.grad)
print("Gradients of opacities:", opacities.grad)
print("Gradients of viewmats:", viewmats.grad.max())
print("Gradients of Ks:", Ks.grad)

What we have observed was

Gradients of viewmats: tensor(0., device='cuda:0')

While this value is very large with 3dgs.

I am wondering if this is designed.

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

1 participant